mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor(bot): separate MatchClear from ConfirmClear
This commit is contained in:
parent
f06fdb38ef
commit
f9abcc68c4
9 changed files with 28 additions and 36 deletions
|
|
@ -88,15 +88,7 @@ public static class ContextArgumentsExt
|
|||
return potentialMatches.Any(potentialMatch => flags.Contains(potentialMatch));
|
||||
}
|
||||
|
||||
public static async Task<bool> MatchClear(this Context ctx, string toClear = null)
|
||||
{
|
||||
var matched = ctx.MatchClearInner();
|
||||
if (matched && toClear != null)
|
||||
return await ctx.ConfirmClear(toClear);
|
||||
return matched;
|
||||
}
|
||||
|
||||
private static bool MatchClearInner(this Context ctx)
|
||||
public static bool MatchClear(this Context ctx)
|
||||
=> ctx.Match("clear", "reset", "default") || ctx.MatchFlag("c", "clear");
|
||||
|
||||
public static bool MatchRaw(this Context ctx) =>
|
||||
|
|
@ -111,7 +103,7 @@ public static class ContextArgumentsExt
|
|||
|
||||
public static bool? MatchToggleOrNull(this Context ctx, bool? defaultValue = null)
|
||||
{
|
||||
if (defaultValue != null && ctx.MatchClearInner())
|
||||
if (defaultValue != null && ctx.MatchClear())
|
||||
return defaultValue.Value;
|
||||
|
||||
var yesToggles = new[] { "yes", "on", "enable", "enabled", "true" };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue