From 4dc460a2692b1d26ae5ae6231de301910203ae3b Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Sun, 17 Dec 2023 21:35:09 +0300 Subject: [PATCH] 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 --- locale/Messages.resx | 7 +++++-- locale/Messages.ru.resx | 7 +++++-- locale/Messages.tt-ru.resx | 7 +++++-- src/Commands/AboutCommandGroup.cs | 18 ++++++++++++------ .../Events/ErrorLoggingPostExecutionEvent.cs | 16 +++++++++++++++- src/Messages.Designer.cs | 16 ++++++++++++---- src/Octobot.cs | 3 +++ src/Responders/GuildLoadedResponder.cs | 12 ++++++++++-- .../Update/ScheduledEventUpdateService.cs | 2 +- 9 files changed, 68 insertions(+), 20 deletions(-) diff --git a/locale/Messages.resx b/locale/Messages.resx index f145ab2..743dd93 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -348,7 +348,7 @@ The event will start at {0} until {1} in {2} - + Open Event Info @@ -396,7 +396,7 @@ Developers: - + Octobot's source code @@ -582,4 +582,7 @@ Contact the developers if the problem occurs again. + + Report an issue + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 5b97eda..67a1d29 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -345,7 +345,7 @@ Событие пройдёт с {0} до {1} в {2} - + Открыть сведения о событии @@ -396,7 +396,7 @@ Разработчики: - + Исходный код Octobot @@ -582,4 +582,7 @@ Обратись к разработчикам, если проблема возникнет снова. + + Сообщить о проблеме + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index 2761827..4050d43 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -348,7 +348,7 @@ движуха будет происходить с {0} до {1} в {2} - + открыть ивент @@ -396,7 +396,7 @@ девелоперы: - + репа Octobot (тык) @@ -582,4 +582,7 @@ если ты это читаешь второй раз за сегодня, пиши разрабам + + зарепортить баг + diff --git a/src/Commands/AboutCommandGroup.cs b/src/Commands/AboutCommandGroup.cs index 4b20a63..2c1e770 100644 --- a/src/Commands/AboutCommandGroup.cs +++ b/src/Commands/AboutCommandGroup.cs @@ -33,8 +33,6 @@ public class AboutCommandGroup : CommandGroup ("neroduckale", new Snowflake(474943797063843851)) }; - private const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot"; - private readonly ICommandContext _context; private readonly IFeedbackService _feedback; private readonly GuildDataService _guildData; @@ -101,16 +99,24 @@ public class AboutCommandGroup : CommandGroup .WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png") .Build(); - var button = new ButtonComponent( + var repositoryButton = new ButtonComponent( ButtonComponentStyle.Link, - Messages.AboutTitleRepository, - URL: RepositoryUrl + Messages.ButtonOpenRepository, + 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, new FeedbackMessageOptions(MessageComponents: new[] { - new ActionRowComponent(new[] { button }) + new ActionRowComponent(new[] { repositoryButton, issuesButton }) }), ct); } } diff --git a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs index 2d5f606..87cfc84 100644 --- a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs +++ b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs @@ -1,8 +1,11 @@ using JetBrains.Annotations; using Microsoft.Extensions.Logging; using Octobot.Extensions; +using Remora.Discord.API.Abstractions.Objects; using Remora.Discord.API.Abstractions.Rest; +using Remora.Discord.API.Objects; using Remora.Discord.Commands.Contexts; +using Remora.Discord.Commands.Feedback.Messages; using Remora.Discord.Commands.Feedback.Services; using Remora.Discord.Commands.Services; using Remora.Discord.Extensions.Embeds; @@ -65,6 +68,17 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent .WithColour(ColorsList.Red) .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); } } diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index 33ba7b3..767bd5b 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -534,9 +534,9 @@ namespace Octobot { } } - internal static string OpenEventInfoButton { + internal static string ButtonOpenEventInfo { 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 { - return ResourceManager.GetString("AboutTitleRepository", resourceCulture); + return ResourceManager.GetString("ButtonOpenRepository", resourceCulture); } } @@ -1028,5 +1028,13 @@ namespace Octobot { return ResourceManager.GetString("ContactDevelopers", resourceCulture); } } + + internal static string ButtonReportIssue + { + get + { + return ResourceManager.GetString("ButtonReportIssue", resourceCulture); + } + } } } diff --git a/src/Octobot.cs b/src/Octobot.cs index 07bc058..1806330 100644 --- a/src/Octobot.cs +++ b/src/Octobot.cs @@ -27,6 +27,9 @@ public sealed class Octobot public static readonly AllowedMentions NoMentions = new( Array.Empty(), Array.Empty(), Array.Empty()); + public const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot"; + public const string IssuesUrl = $"{RepositoryUrl}/issues"; + public static async Task Main(string[] args) { var host = CreateHostBuilder(args).UseConsoleLifetime().Build(); diff --git a/src/Responders/GuildLoadedResponder.cs b/src/Responders/GuildLoadedResponder.cs index cc720c8..2d66a3b 100644 --- a/src/Responders/GuildLoadedResponder.cs +++ b/src/Responders/GuildLoadedResponder.cs @@ -7,6 +7,7 @@ using Remora.Discord.API.Abstractions.Gateway.Events; using Remora.Discord.API.Abstractions.Objects; using Remora.Discord.API.Abstractions.Rest; using Remora.Discord.API.Gateway.Events; +using Remora.Discord.API.Objects; using Remora.Discord.Extensions.Embeds; using Remora.Discord.Gateway.Responders; using Remora.Results; @@ -112,7 +113,14 @@ public class GuildLoadedResponder : IResponder .WithColour(ColorsList.Red) .Build(); - return await _channelApi.CreateMessageWithEmbedResultAsync( - channel, embedResult: errorEmbed, ct: ct); + var issuesButton = new ButtonComponent( + 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); } } diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs index 38fe4a7..dd9be0d 100644 --- a/src/Services/Update/ScheduledEventUpdateService.cs +++ b/src/Services/Update/ScheduledEventUpdateService.cs @@ -222,7 +222,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService var button = new ButtonComponent( ButtonComponentStyle.Link, - Messages.OpenEventInfoButton, + Messages.ButtonOpenEventInfo, new PartialEmoji(Name: "📋"), URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}" );