From ca49231c86f833abc13a9d15de44e68fad2aad63 Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:59:25 +0300 Subject: [PATCH] Disable issue report button if dirty version detected (#275) In this PR, I'm disabling the Report Issue button if a "dirty" version is detected. This is done just in case so that "smart" developers don't accidentally report a bug that they themselves created. --------- Signed-off-by: mctaylors --- locale/Messages.resx | 3 +++ locale/Messages.ru.resx | 3 +++ locale/Messages.tt-ru.resx | 3 +++ src/BuildInfo.cs | 2 +- src/Commands/AboutCommandGroup.cs | 7 +++++-- src/Commands/Events/ErrorLoggingPostExecutionEvent.cs | 7 +++++-- src/Messages.Designer.cs | 6 ++++++ src/Responders/GuildLoadedResponder.cs | 7 +++++-- 8 files changed, 31 insertions(+), 7 deletions(-) diff --git a/locale/Messages.resx b/locale/Messages.resx index de99b4e..f7500b6 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -669,4 +669,7 @@ Welcome messages channel + + Can't report an issue in the development version + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 991ffcc..e28b405 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -669,4 +669,7 @@ Канал для приветствий + + Нельзя сообщить о проблеме в версии под разработкой + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index a5ba94d..58e1178 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -669,4 +669,7 @@ канал куда говорить здравствуйте + + вот иди сам и почини что сломал + diff --git a/src/BuildInfo.cs b/src/BuildInfo.cs index 50f86a2..c704328 100644 --- a/src/BuildInfo.cs +++ b/src/BuildInfo.cs @@ -34,7 +34,7 @@ public static class BuildInfo } } - private static bool IsDirty + public static bool IsDirty { get { diff --git a/src/Commands/AboutCommandGroup.cs b/src/Commands/AboutCommandGroup.cs index 05b1855..ebfe0f2 100644 --- a/src/Commands/AboutCommandGroup.cs +++ b/src/Commands/AboutCommandGroup.cs @@ -113,9 +113,12 @@ public class AboutCommandGroup : CommandGroup var issuesButton = new ButtonComponent( ButtonComponentStyle.Link, - Messages.ButtonReportIssue, + BuildInfo.IsDirty + ? Messages.ButtonDirty + : Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: BuildInfo.IssuesUrl + URL: BuildInfo.IssuesUrl, + IsDisabled: BuildInfo.IsDirty ); return await _feedback.SendContextualEmbedResultAsync(embed, diff --git a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs index 5d7830b..6f39690 100644 --- a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs +++ b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs @@ -70,9 +70,12 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent var issuesButton = new ButtonComponent( ButtonComponentStyle.Link, - Messages.ButtonReportIssue, + BuildInfo.IsDirty + ? Messages.ButtonDirty + : Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: BuildInfo.IssuesUrl + URL: BuildInfo.IssuesUrl, + IsDisabled: BuildInfo.IsDirty ); return await _feedback.SendContextualEmbedResultAsync(embed, diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index 7b44c44..3d452a6 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1204,5 +1204,11 @@ namespace Octobot { return ResourceManager.GetString("SettingsWelcomeMessagesChannel", resourceCulture); } } + + internal static string ButtonDirty { + get { + return ResourceManager.GetString("ButtonDirty", resourceCulture); + } + } } } diff --git a/src/Responders/GuildLoadedResponder.cs b/src/Responders/GuildLoadedResponder.cs index a0636f6..e60dd4f 100644 --- a/src/Responders/GuildLoadedResponder.cs +++ b/src/Responders/GuildLoadedResponder.cs @@ -115,9 +115,12 @@ public class GuildLoadedResponder : IResponder var issuesButton = new ButtonComponent( ButtonComponentStyle.Link, - Messages.ButtonReportIssue, + BuildInfo.IsDirty + ? Messages.ButtonDirty + : Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: BuildInfo.IssuesUrl + URL: BuildInfo.IssuesUrl, + IsDisabled: BuildInfo.IsDirty ); return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,