feat(bot): allow 'pk;logclean' in DMs

This commit is contained in:
spiral
2022-06-21 11:13:24 -04:00
parent cfd9dff6c5
commit b04b6e38d2
2 changed files with 25 additions and 20 deletions

View File

@@ -103,6 +103,13 @@ public static class ContextArgumentsExt
ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw");
public static bool MatchToggle(this Context ctx, bool? defaultValue = null)
{
var value = ctx.MatchToggleOrNull(defaultValue);
if (value == null) throw new PKError("You must pass either \"on\" or \"off\" to this command.");
return value.Value;
}
public static bool? MatchToggleOrNull(this Context ctx, bool? defaultValue = null)
{
if (defaultValue != null && ctx.MatchClearInner())
return defaultValue.Value;
@@ -114,8 +121,7 @@ public static class ContextArgumentsExt
return true;
else if (ctx.Match(noToggles) || ctx.MatchFlag(noToggles))
return false;
else
throw new PKError("You must pass either \"on\" or \"off\" to this command.");
else return null;
}
public static (ulong? messageId, ulong? channelId) MatchMessage(this Context ctx, bool parseRawMessageId)