Properly skip flag parsing when handling proxy tags

This commit is contained in:
Ske 2020-02-22 15:21:48 +01:00
parent 8d3be79d33
commit 75947301f1
2 changed files with 5 additions and 5 deletions

View File

@ -50,7 +50,7 @@ namespace PluralKit.Bot
public string PopArgument() => _parameters.Pop();
public string PeekArgument() => _parameters.Peek();
public string RemainderOrNull(bool skipFlags = true) => _parameters.Remainder(skipFlags).Length == 0 ? null : _parameters.Remainder(skipFlags);
public bool HasNext() => RemainderOrNull() != null;
public bool HasNext(bool skipFlags = true) => RemainderOrNull(skipFlags) != null;
public string FullCommand => _parameters.FullCommand;
public Task<IUserMessage> Reply(string text = null, Embed embed = null) =>

View File

@ -44,7 +44,7 @@ namespace PluralKit.Bot
// "Sub"command: no arguments clearing
// Also matches the pseudo-subcommand "text" which is equivalent to empty proxy tags on both sides.
if (!ctx.HasNext() || ctx.Match("clear", "purge", "clean", "removeall"))
if (!ctx.HasNext(skipFlags: false) || ctx.Match("clear", "purge", "clean", "removeall"))
{
// If we already have multiple tags, this would clear everything, so prompt that
if (target.ProxyTags.Count > 1)
@ -63,7 +63,7 @@ namespace PluralKit.Bot
// Subcommand: "add"
else if (ctx.Match("add", "append"))
{
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`).");
if (!ctx.HasNext(skipFlags: false)) throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`).");
var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target);
@ -83,7 +83,7 @@ namespace PluralKit.Bot
// Subcommand: "remove"
else if (ctx.Match("remove", "delete"))
{
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`).");
if (!ctx.HasNext(skipFlags: false)) throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`).");
var tagToRemove = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target);
@ -100,7 +100,7 @@ namespace PluralKit.Bot
// Subcommand: bare proxy tag given
else
{
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to set (eg. `[text]` or `J:text`).");
if (!ctx.HasNext(skipFlags: false)) throw new PKSyntaxError("You must pass an example proxy to set (eg. `[text]` or `J:text`).");
var requestedTag = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target);