Add simple response function to the InteractionBase to reduce the InteractionResponse copying

This commit is contained in:
Daan Boerlage 2021-11-05 17:45:11 +01:00
parent 5a520ff567
commit e74aeb1403
Signed by: daan
GPG key ID: FCE070E1E4956606
3 changed files with 9 additions and 11 deletions

View file

@ -26,13 +26,18 @@ namespace Geekbot.Core.Interactions
} }
public virtual InteractionResponse GetExceptionResponse(Interaction interaction) public virtual InteractionResponse GetExceptionResponse(Interaction interaction)
{
return SimpleResponse(Localization.Internal.SomethingWentWrong);
}
protected InteractionResponse SimpleResponse(string message)
{ {
return new InteractionResponse() return new InteractionResponse()
{ {
Type = InteractionResponseType.ChannelMessageWithSource, Type = InteractionResponseType.ChannelMessageWithSource,
Data = new() Data = new()
{ {
Content = Localization.Internal.SomethingWentWrong Content = message
} }
}; };
} }

View file

@ -96,7 +96,7 @@ namespace Geekbot.Web.Commands
} }
}; };
return Task.FromResult(interactionResponse); return Task.FromResult(SimpleResponse(res));
} }
} }
} }

View file

@ -60,14 +60,7 @@ namespace Geekbot.Web.Commands
guess guess
); );
return new InteractionResponse() return SimpleResponse(res);
{
Type = InteractionResponseType.ChannelMessageWithSource,
Data = new InteractionResponseData()
{
Content = res
}
};
} }
} }
} }