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)
{
return SimpleResponse(Localization.Internal.SomethingWentWrong);
}
protected InteractionResponse SimpleResponse(string message)
{
return new InteractionResponse()
{
Type = InteractionResponseType.ChannelMessageWithSource,
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

@ -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);
}
}
}