elliebot/src/EllieBot/_common/CleanupModuleBase.cs

25 lines
No EOL
632 B
C#

#nullable disable
namespace EllieBot.Common;
public abstract class CleanupModuleBase : EllieModule
{
protected async Task ConfirmActionInternalAsync(string name, Func<Task> action)
{
try
{
var embed = _sender.CreateEmbed()
.WithTitle(GetText(strs.sql_confirm_exec))
.WithDescription(name);
if (!await PromptUserConfirmAsync(embed))
return;
await action();
await ctx.OkAsync();
}
catch (Exception ex)
{
await Response().Error(ex.ToString()).SendAsync();
}
}
}