From aad9f04b6f6dd00a9e7121089c47e7d686003d86 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 20 Jan 2022 23:59:04 -0500 Subject: [PATCH] feat: add 'enabled' phrasing and MatchFlag to MatchToggle, clean up --- PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs index 5a7cf9be..63e4f92f 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs @@ -101,9 +101,12 @@ public static class ContextArgumentsExt public static bool MatchToggle(this Context ctx) { - if (ctx.Match("yes", "on", "enable", "true")) + var yesToggles = new[] { "yes", "on", "enable", "enabled", "true" }; + var noToggles = new[] { "no", "off", "disable", "disabled", "false" }; + + if (ctx.Match(yesToggles) || ctx.MatchFlag(yesToggles)) return true; - else if (ctx.Match("no", "off", "disable", "false")) + else if (ctx.Match(noToggles) || ctx.MatchFlag(noToggles)) return false; else throw new PKError("You must pass either \"on\" or \"off\" to this command.");