From c1b8394e1b092d9d7b459f2969cad5ebb21e1b24 Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Thu, 18 Mar 2021 12:06:41 +0100 Subject: [PATCH] Add a !neutral command for karma, it does nothing. --- src/Bot/Commands/User/Karma.cs | 41 ++++++++++++++++++++++++++ src/Bot/Localization/Karma.Designer.cs | 9 ++++++ src/Bot/Localization/Karma.de-ch.resx | 3 ++ src/Bot/Localization/Karma.resx | 3 ++ 4 files changed, 56 insertions(+) diff --git a/src/Bot/Commands/User/Karma.cs b/src/Bot/Commands/User/Karma.cs index 4778bce..3ba8650 100644 --- a/src/Bot/Commands/User/Karma.cs +++ b/src/Bot/Commands/User/Karma.cs @@ -115,6 +115,47 @@ namespace Geekbot.Bot.Commands.User await ErrorHandler.HandleCommandException(e, Context); } } + + [Command("neutral", RunMode = RunMode.Async)] + [Summary("Do nothing to someones karma")] + public async Task Neutral([Summary("@someone")] IUser user) + { + try + { + var actor = await GetUser(Context.User.Id); + if (user.Id == Context.User.Id) + { + await ReplyAsync(string.Format(Localization.Karma.CannotChangeOwnDown, Context.User.Username)); + return; + } + + if (TimeoutFinished(actor.TimeOut)) + { + var formatedWaitTime = DateLocalization.FormatDateTimeAsRemaining(actor.TimeOut.AddMinutes(3)); + await ReplyAsync(string.Format(Localization.Karma.WaitUntill, Context.User.Username, formatedWaitTime)); + return; + } + + var target = await GetUser(user.Id); + + var eb = new EmbedBuilder(); + eb.WithAuthor(new EmbedAuthorBuilder() + .WithIconUrl(user.GetAvatarUrl()) + .WithName(user.Username)); + + eb.WithColor(new Color(138, 219, 146)); + eb.Title = Localization.Karma.Neutral; + eb.AddInlineField(Localization.Karma.By, Context.User.Username); + eb.AddInlineField(Localization.Karma.Amount, "0"); + eb.AddInlineField(Localization.Karma.Current, target.Karma); + await ReplyAsync("", false, eb.Build()); + + } + catch (Exception e) + { + await ErrorHandler.HandleCommandException(e, Context); + } + } private bool TimeoutFinished(DateTimeOffset lastKarma) { diff --git a/src/Bot/Localization/Karma.Designer.cs b/src/Bot/Localization/Karma.Designer.cs index 4191fa2..71cab3b 100644 --- a/src/Bot/Localization/Karma.Designer.cs +++ b/src/Bot/Localization/Karma.Designer.cs @@ -123,6 +123,15 @@ namespace Geekbot.Bot.Localization { } } + /// + /// Looks up a localized string similar to Neutral Karma. + /// + internal static string Neutral { + get { + return ResourceManager.GetString("Neutral", resourceCulture); + } + } + /// /// Looks up a localized string similar to Sorry {0}, but you have to wait {1} before you can give karma again.... /// diff --git a/src/Bot/Localization/Karma.de-ch.resx b/src/Bot/Localization/Karma.de-ch.resx index 5605f8b..7b739b7 100644 --- a/src/Bot/Localization/Karma.de-ch.resx +++ b/src/Bot/Localization/Karma.de-ch.resx @@ -35,4 +35,7 @@ Karma gsenkt + + Neutral Karma + \ No newline at end of file diff --git a/src/Bot/Localization/Karma.resx b/src/Bot/Localization/Karma.resx index 3a8fe5a..2ebea1d 100644 --- a/src/Bot/Localization/Karma.resx +++ b/src/Bot/Localization/Karma.resx @@ -42,4 +42,7 @@ Karma lowered + + Neutral Karma + \ No newline at end of file