From 193a65149567f60e1f942cf9114a99fb953bcede Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Mon, 27 Dec 2021 21:58:49 +0800 Subject: [PATCH] Move the error embed from /karma into the embad class as a static method so it can be used by other commands as well --- src/Commands/Karma/Karma.cs | 14 ++------------ src/Interactions/Embed/Embed.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Commands/Karma/Karma.cs b/src/Commands/Karma/Karma.cs index a02b388..7cde07e 100644 --- a/src/Commands/Karma/Karma.cs +++ b/src/Commands/Karma/Karma.cs @@ -34,7 +34,7 @@ public class Karma KarmaChange.Down => Localization.Karma.CannotChangeOwnDown, _ => throw new ArgumentOutOfRangeException(nameof(change), change, null) }; - return CreateErrorEmbed(string.Format(message, author.Username)); + return Embed.ErrorEmbed(string.Format(message, author.Username)); } var timeoutMinutes = 3; @@ -42,7 +42,7 @@ public class Karma { var remaining = authorRecord.TimeOut.AddMinutes(timeoutMinutes) - DateTimeOffset.Now.ToUniversalTime(); var formatedWaitTime = DateLocalization.FormatDateTimeAsRemaining(remaining); - return CreateErrorEmbed(string.Format(Localization.Karma.WaitUntill, author.Username, formatedWaitTime)); + return Embed.ErrorEmbed(string.Format(Localization.Karma.WaitUntill, author.Username, formatedWaitTime)); } // Get the values for the change direction @@ -80,16 +80,6 @@ public class Karma eb.AddInlineField(Localization.Karma.Current, targetUserRecord.Karma.ToString()); return eb; } - - private Embed CreateErrorEmbed(string errorMessage) - { - var eb = new Embed() - { - Description = errorMessage - }; - eb.SetColor(Color.Red); - return eb; - } private async Task GetUser(long userId) { diff --git a/src/Interactions/Embed/Embed.cs b/src/Interactions/Embed/Embed.cs index d392e7b..9f29fbf 100644 --- a/src/Interactions/Embed/Embed.cs +++ b/src/Interactions/Embed/Embed.cs @@ -124,5 +124,15 @@ namespace Geekbot.Interactions.Embed return eb; } + + public static Embed ErrorEmbed(string errorMessage) + { + var eb = new Embed() + { + Description = errorMessage + }; + eb.SetColor(System.Drawing.Color.Red); + return eb; + } } } \ No newline at end of file