feat: better command parsing for pk;config

This commit is contained in:
spiral
2022-01-19 18:59:44 -05:00
parent 426d753827
commit 1626e0f548
2 changed files with 48 additions and 48 deletions

View File

@@ -99,6 +99,16 @@ public static class ContextArgumentsExt
public static bool MatchRaw(this Context ctx) =>
ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw");
public static bool MatchToggle(this Context ctx)
{
if (ctx.Match("yes", "on", "enable"))
return true;
else if (ctx.Match("no", "off", "disable"))
return false;
else
throw new PKError("You must pass either \"on\" or \"off\" to this command.");
}
public static (ulong? messageId, ulong? channelId) MatchMessage(this Context ctx, bool parseRawMessageId)
{
if (ctx.Message.Type == Message.MessageType.Reply && ctx.Message.MessageReference?.MessageId != null)