From e74aeb1403936310ddf30bbb1cd30b6ab4a823d3 Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Fri, 5 Nov 2021 17:45:11 +0100 Subject: [PATCH] Add simple response function to the InteractionBase to reduce the InteractionResponse copying --- src/Core/Interactions/InteractionBase.cs | 7 ++++++- src/Web/Commands/Rank.cs | 2 +- src/Web/Commands/Roll.cs | 11 ++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Core/Interactions/InteractionBase.cs b/src/Core/Interactions/InteractionBase.cs index 26c0a3c..b763dcb 100644 --- a/src/Core/Interactions/InteractionBase.cs +++ b/src/Core/Interactions/InteractionBase.cs @@ -26,13 +26,18 @@ namespace Geekbot.Core.Interactions } public virtual InteractionResponse GetExceptionResponse(Interaction interaction) + { + return SimpleResponse(Localization.Internal.SomethingWentWrong); + } + + protected InteractionResponse SimpleResponse(string message) { return new InteractionResponse() { Type = InteractionResponseType.ChannelMessageWithSource, Data = new() { - Content = Localization.Internal.SomethingWentWrong + Content = message } }; } diff --git a/src/Web/Commands/Rank.cs b/src/Web/Commands/Rank.cs index e0d3deb..3fdcb62 100644 --- a/src/Web/Commands/Rank.cs +++ b/src/Web/Commands/Rank.cs @@ -96,7 +96,7 @@ namespace Geekbot.Web.Commands } }; - return Task.FromResult(interactionResponse); + return Task.FromResult(SimpleResponse(res)); } } } \ No newline at end of file diff --git a/src/Web/Commands/Roll.cs b/src/Web/Commands/Roll.cs index 4d1f60a..7134ec5 100644 --- a/src/Web/Commands/Roll.cs +++ b/src/Web/Commands/Roll.cs @@ -59,15 +59,8 @@ namespace Geekbot.Web.Commands interaction.Member.Nick ?? interaction.Member.User.Username, guess ); - - return new InteractionResponse() - { - Type = InteractionResponseType.ChannelMessageWithSource, - Data = new InteractionResponseData() - { - Content = res - } - }; + + return SimpleResponse(res); } } } \ No newline at end of file