Add command to delete all switches

This commit is contained in:
Ske
2019-11-02 22:46:51 +01:00
parent 1e1f2acdc3
commit 7c3b4b9af9
4 changed files with 25 additions and 0 deletions

View File

@@ -119,6 +119,17 @@ namespace PluralKit.Bot.Commands
public async Task SwitchDelete(Context ctx)
{
ctx.CheckSystem();
if (ctx.Match("all", "clear"))
{
// Subcommand: "delete all"
var purgeMsg = await ctx.Reply($"{Emojis.Warn} This will delete *all registered switches* in your system. Are you sure you want to proceed?");
if (!await ctx.PromptYesNo(purgeMsg))
throw Errors.GenericCancelled();
await _data.DeleteAllSwitches(ctx.System);
await ctx.Reply($"{Emojis.Success} Cleared system switches!");
return;
}
// Fetch the last two switches for the system to do bounds checking on
var lastTwoSwitches = (await _data.GetSwitches(ctx.System, 2)).ToArray();