1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

Add issue button w/ some button updates (#221)

In this PR, I've added a "Report an issue" button and a few more
button-related changes:
- Add "Report an issue" button
- Add icon for "Octobot's source code"
- Rename `AboutTitleRepository` to `ButtonOpenRepository`
- Rename `OpenEventInfoButton` to `ButtonOpenEventInfo` to be consistent
with other language string names
- Rename `ColorsList.cs` to `Miscellaneous.cs`
- Add public const strings in `Octobot.cs` to get repository & issues links

---------

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-17 21:35:09 +03:00 committed by GitHub
parent 4581b402aa
commit 4dc460a269
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 68 additions and 20 deletions

View file

@ -348,7 +348,7 @@
<data name="DescriptionExternalEventCreated" xml:space="preserve"> <data name="DescriptionExternalEventCreated" xml:space="preserve">
<value>The event will start at {0} until {1} in {2}</value> <value>The event will start at {0} until {1} in {2}</value>
</data> </data>
<data name="OpenEventInfoButton" xml:space="preserve"> <data name="ButtonOpenEventInfo" xml:space="preserve">
<value>Open Event Info</value> <value>Open Event Info</value>
</data> </data>
<data name="EventDuration" xml:space="preserve"> <data name="EventDuration" xml:space="preserve">
@ -396,7 +396,7 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>Developers:</value> <value>Developers:</value>
</data> </data>
<data name="AboutTitleRepository" xml:space="preserve"> <data name="ButtonOpenRepository" xml:space="preserve">
<value>Octobot's source code</value> <value>Octobot's source code</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
@ -582,4 +582,7 @@
<data name="ContactDevelopers" xml:space="preserve"> <data name="ContactDevelopers" xml:space="preserve">
<value>Contact the developers if the problem occurs again.</value> <value>Contact the developers if the problem occurs again.</value>
</data> </data>
<data name="ButtonReportIssue" xml:space="preserve">
<value>Report an issue</value>
</data>
</root> </root>

View file

@ -345,7 +345,7 @@
<data name="DescriptionExternalEventCreated" xml:space="preserve"> <data name="DescriptionExternalEventCreated" xml:space="preserve">
<value>Событие пройдёт с {0} до {1} в {2}</value> <value>Событие пройдёт с {0} до {1} в {2}</value>
</data> </data>
<data name="OpenEventInfoButton" xml:space="preserve"> <data name="ButtonOpenEventInfo" xml:space="preserve">
<value>Открыть сведения о событии</value> <value>Открыть сведения о событии</value>
</data> </data>
<data name="EventDuration" xml:space="preserve"> <data name="EventDuration" xml:space="preserve">
@ -396,7 +396,7 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>Разработчики:</value> <value>Разработчики:</value>
</data> </data>
<data name="AboutTitleRepository" xml:space="preserve"> <data name="ButtonOpenRepository" xml:space="preserve">
<value>Исходный код Octobot</value> <value>Исходный код Octobot</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
@ -582,4 +582,7 @@
<data name="ContactDevelopers" xml:space="preserve"> <data name="ContactDevelopers" xml:space="preserve">
<value>Обратись к разработчикам, если проблема возникнет снова.</value> <value>Обратись к разработчикам, если проблема возникнет снова.</value>
</data> </data>
<data name="ButtonReportIssue" xml:space="preserve">
<value>Сообщить о проблеме</value>
</data>
</root> </root>

View file

@ -348,7 +348,7 @@
<data name="DescriptionExternalEventCreated" xml:space="preserve"> <data name="DescriptionExternalEventCreated" xml:space="preserve">
<value>движуха будет происходить с {0} до {1} в {2}</value> <value>движуха будет происходить с {0} до {1} в {2}</value>
</data> </data>
<data name="OpenEventInfoButton" xml:space="preserve"> <data name="ButtonOpenEventInfo" xml:space="preserve">
<value>открыть ивент</value> <value>открыть ивент</value>
</data> </data>
<data name="EventDuration" xml:space="preserve"> <data name="EventDuration" xml:space="preserve">
@ -396,7 +396,7 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>девелоперы:</value> <value>девелоперы:</value>
</data> </data>
<data name="AboutTitleRepository" xml:space="preserve"> <data name="ButtonOpenRepository" xml:space="preserve">
<value>репа Octobot (тык)</value> <value>репа Octobot (тык)</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
@ -582,4 +582,7 @@
<data name="ContactDevelopers" xml:space="preserve"> <data name="ContactDevelopers" xml:space="preserve">
<value>если ты это читаешь второй раз за сегодня, пиши разрабам</value> <value>если ты это читаешь второй раз за сегодня, пиши разрабам</value>
</data> </data>
<data name="ButtonReportIssue" xml:space="preserve">
<value>зарепортить баг</value>
</data>
</root> </root>

View file

@ -33,8 +33,6 @@ public class AboutCommandGroup : CommandGroup
("neroduckale", new Snowflake(474943797063843851)) ("neroduckale", new Snowflake(474943797063843851))
}; };
private const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot";
private readonly ICommandContext _context; private readonly ICommandContext _context;
private readonly IFeedbackService _feedback; private readonly IFeedbackService _feedback;
private readonly GuildDataService _guildData; private readonly GuildDataService _guildData;
@ -101,16 +99,24 @@ public class AboutCommandGroup : CommandGroup
.WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png") .WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png")
.Build(); .Build();
var button = new ButtonComponent( var repositoryButton = new ButtonComponent(
ButtonComponentStyle.Link, ButtonComponentStyle.Link,
Messages.AboutTitleRepository, Messages.ButtonOpenRepository,
URL: RepositoryUrl new PartialEmoji(Name: "🌐"),
URL: Octobot.RepositoryUrl
);
var issuesButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
); );
return await _feedback.SendContextualEmbedResultAsync(embed, return await _feedback.SendContextualEmbedResultAsync(embed,
new FeedbackMessageOptions(MessageComponents: new[] new FeedbackMessageOptions(MessageComponents: new[]
{ {
new ActionRowComponent(new[] { button }) new ActionRowComponent(new[] { repositoryButton, issuesButton })
}), ct); }), ct);
} }
} }

View file

@ -1,8 +1,11 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Octobot.Extensions; using Octobot.Extensions;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest; using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.API.Objects;
using Remora.Discord.Commands.Contexts; using Remora.Discord.Commands.Contexts;
using Remora.Discord.Commands.Feedback.Messages;
using Remora.Discord.Commands.Feedback.Services; using Remora.Discord.Commands.Feedback.Services;
using Remora.Discord.Commands.Services; using Remora.Discord.Commands.Services;
using Remora.Discord.Extensions.Embeds; using Remora.Discord.Extensions.Embeds;
@ -65,6 +68,17 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
.WithColour(ColorsList.Red) .WithColour(ColorsList.Red)
.Build(); .Build();
return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct); var issuesButton = new ButtonComponent(
ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
);
return await _feedback.SendContextualEmbedResultAsync(embed,
new FeedbackMessageOptions(MessageComponents: new[]
{
new ActionRowComponent(new[] { issuesButton })
}), ct);
} }
} }

View file

@ -534,9 +534,9 @@ namespace Octobot {
} }
} }
internal static string OpenEventInfoButton { internal static string ButtonOpenEventInfo {
get { get {
return ResourceManager.GetString("OpenEventInfoButton", resourceCulture); return ResourceManager.GetString("ButtonOpenEventInfo", resourceCulture);
} }
} }
@ -630,9 +630,9 @@ namespace Octobot {
} }
} }
internal static string AboutTitleRepository { internal static string ButtonOpenRepository {
get { get {
return ResourceManager.GetString("AboutTitleRepository", resourceCulture); return ResourceManager.GetString("ButtonOpenRepository", resourceCulture);
} }
} }
@ -1028,5 +1028,13 @@ namespace Octobot {
return ResourceManager.GetString("ContactDevelopers", resourceCulture); return ResourceManager.GetString("ContactDevelopers", resourceCulture);
} }
} }
internal static string ButtonReportIssue
{
get
{
return ResourceManager.GetString("ButtonReportIssue", resourceCulture);
}
}
} }
} }

View file

@ -27,6 +27,9 @@ public sealed class Octobot
public static readonly AllowedMentions NoMentions = new( public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>()); Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
public const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot";
public const string IssuesUrl = $"{RepositoryUrl}/issues";
public static async Task Main(string[] args) public static async Task Main(string[] args)
{ {
var host = CreateHostBuilder(args).UseConsoleLifetime().Build(); var host = CreateHostBuilder(args).UseConsoleLifetime().Build();

View file

@ -7,6 +7,7 @@ using Remora.Discord.API.Abstractions.Gateway.Events;
using Remora.Discord.API.Abstractions.Objects; using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest; using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.API.Gateway.Events; using Remora.Discord.API.Gateway.Events;
using Remora.Discord.API.Objects;
using Remora.Discord.Extensions.Embeds; using Remora.Discord.Extensions.Embeds;
using Remora.Discord.Gateway.Responders; using Remora.Discord.Gateway.Responders;
using Remora.Results; using Remora.Results;
@ -112,7 +113,14 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
.WithColour(ColorsList.Red) .WithColour(ColorsList.Red)
.Build(); .Build();
return await _channelApi.CreateMessageWithEmbedResultAsync( var issuesButton = new ButtonComponent(
channel, embedResult: errorEmbed, ct: ct); ButtonComponentStyle.Link,
Messages.ButtonReportIssue,
new PartialEmoji(Name: "⚠️"),
URL: Octobot.IssuesUrl
);
return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,
components: new[] { new ActionRowComponent(new[] { issuesButton }) }, ct: ct);
} }
} }

View file

@ -222,7 +222,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
var button = new ButtonComponent( var button = new ButtonComponent(
ButtonComponentStyle.Link, ButtonComponentStyle.Link,
Messages.OpenEventInfoButton, Messages.ButtonOpenEventInfo,
new PartialEmoji(Name: "📋"), new PartialEmoji(Name: "📋"),
URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}" URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}"
); );