From a5a3eb86dd8a4c38f81f3a76a72b954e0b1f2611 Mon Sep 17 00:00:00 2001 From: mctaylors Date: Tue, 19 Mar 2024 19:37:59 +0300 Subject: [PATCH] uhhh ehhh Signed-off-by: mctaylors --- Octobot.csproj | 6 +-- src/BuildInfo.cs | 54 +++++++++++++++++++ src/Commands/AboutCommandGroup.cs | 11 ++-- .../Events/ErrorLoggingPostExecutionEvent.cs | 2 +- src/Responders/GuildLoadedResponder.cs | 2 +- 5 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 src/BuildInfo.cs diff --git a/Octobot.csproj b/Octobot.csproj index 53a35c5..bdfb46a 100644 --- a/Octobot.csproj +++ b/Octobot.csproj @@ -17,14 +17,12 @@ en A general-purpose Discord bot for moderation written in C# docs/octobot.ico + false - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/BuildInfo.cs b/src/BuildInfo.cs new file mode 100644 index 0000000..cbff340 --- /dev/null +++ b/src/BuildInfo.cs @@ -0,0 +1,54 @@ +using JetBrains.Annotations; + +namespace Octobot; + +public static class BuildInfo +{ + public static string RepositoryUrl + { + get + { + return ThisAssembly.Git.RepositoryUrl; + } + } + + public static string Issues + { + get + { + return $"{RepositoryUrl}/issues"; + } + } + + private static string Commit + { + get + { + return ThisAssembly.Git.Commit; + } + } + + private static string Branch + { + get + { + return ThisAssembly.Git.Branch; + } + } + + private static bool IsDirty + { + get + { + return ThisAssembly.Git.IsDirty; + } + } + + public static string Version + { + get + { + return IsDirty ? $"{Branch}-{Commit}-dirty" : $"{Branch}-{Commit}"; + } + } +} diff --git a/src/Commands/AboutCommandGroup.cs b/src/Commands/AboutCommandGroup.cs index 2b649ce..0ba20cd 100644 --- a/src/Commands/AboutCommandGroup.cs +++ b/src/Commands/AboutCommandGroup.cs @@ -101,26 +101,21 @@ public class AboutCommandGroup : CommandGroup .WithDescription(builder.ToString()) .WithColour(ColorsList.Cyan) .WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png") - // ThisAssembly.Git.IsDirty already returns true or false. - // ReSharper disable HeuristicUnreachableCode - .WithFooter(string.Format(Messages.Version, ThisAssembly.Git.IsDirty - ? $"{ThisAssembly.Git.Branch}-{ThisAssembly.Git.Commit}-dirty" - : $"{ThisAssembly.Git.Branch}-{ThisAssembly.Git.Commit}")) - // ReSharper restore HeuristicUnreachableCode + .WithFooter(string.Format(Messages.Version, BuildInfo.Version)) .Build(); var repositoryButton = new ButtonComponent( ButtonComponentStyle.Link, Messages.ButtonOpenRepository, new PartialEmoji(Name: "🌐"), - URL: ThisAssembly.Git.RepositoryUrl + URL: BuildInfo.RepositoryUrl ); var issuesButton = new ButtonComponent( ButtonComponentStyle.Link, Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: $"{ThisAssembly.Git.RepositoryUrl}/issues" + URL: BuildInfo.Issues ); return await _feedback.SendContextualEmbedResultAsync(embed, diff --git a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs index d4cdb8d..08309f9 100644 --- a/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs +++ b/src/Commands/Events/ErrorLoggingPostExecutionEvent.cs @@ -72,7 +72,7 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent ButtonComponentStyle.Link, Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: $"{ThisAssembly.Git.RepositoryUrl}/issues" + URL: BuildInfo.Issues ); return await _feedback.SendContextualEmbedResultAsync(embed, diff --git a/src/Responders/GuildLoadedResponder.cs b/src/Responders/GuildLoadedResponder.cs index 49e4d54..90b9792 100644 --- a/src/Responders/GuildLoadedResponder.cs +++ b/src/Responders/GuildLoadedResponder.cs @@ -117,7 +117,7 @@ public class GuildLoadedResponder : IResponder ButtonComponentStyle.Link, Messages.ButtonReportIssue, new PartialEmoji(Name: "⚠️"), - URL: $"{ThisAssembly.Git.RepositoryUrl}/issues" + URL: BuildInfo.Issues ); return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,