Skip flag parsing when handling proxy tags
This commit is contained in:
parent
de141d629b
commit
493f7b12e5
@ -49,8 +49,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public string PopArgument() => _parameters.Pop();
|
||||
public string PeekArgument() => _parameters.Peek();
|
||||
public string Remainder() => _parameters.Remainder();
|
||||
public string RemainderOrNull() => Remainder().Trim().Length == 0 ? null : Remainder();
|
||||
public string RemainderOrNull(bool skipFlags = true) => _parameters.Remainder(skipFlags).Length == 0 ? null : _parameters.Remainder(skipFlags);
|
||||
public bool HasNext() => RemainderOrNull() != null;
|
||||
public string FullCommand => _parameters.FullCommand;
|
||||
|
||||
|
@ -101,7 +101,9 @@ namespace PluralKit.Bot
|
||||
return _flags;
|
||||
}
|
||||
|
||||
public string Remainder()
|
||||
public string Remainder(bool skipFlags = true)
|
||||
{
|
||||
if (skipFlags)
|
||||
{
|
||||
// Skip all *leading* flags when taking the remainder
|
||||
while (NextWordPosition(_ptr) is {} wp)
|
||||
@ -109,6 +111,7 @@ namespace PluralKit.Bot
|
||||
if (_cmd[wp.startPos] != '-' || wp.wasQuoted) break;
|
||||
_ptr = wp.endPos + wp.advanceAfterWord;
|
||||
}
|
||||
}
|
||||
|
||||
// *Then* get the remainder
|
||||
return _cmd.Substring(Math.Min(_ptr, _cmd.Length)).Trim();
|
||||
|
@ -65,7 +65,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`).");
|
||||
|
||||
var tagToAdd = ParseProxyTags(ctx.RemainderOrNull());
|
||||
var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
|
||||
if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target);
|
||||
if (target.ProxyTags.Contains(tagToAdd))
|
||||
throw Errors.ProxyTagAlreadyExists(tagToAdd, target);
|
||||
@ -85,7 +85,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`).");
|
||||
|
||||
var tagToRemove = ParseProxyTags(ctx.RemainderOrNull());
|
||||
var tagToRemove = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
|
||||
if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target);
|
||||
if (!target.ProxyTags.Contains(tagToRemove))
|
||||
throw Errors.ProxyTagDoesNotExist(tagToRemove, target);
|
||||
@ -102,7 +102,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to set (eg. `[text]` or `J:text`).");
|
||||
|
||||
var requestedTag = ParseProxyTags(ctx.RemainderOrNull());
|
||||
var requestedTag = ParseProxyTags(ctx.RemainderOrNull(skipFlags: false));
|
||||
if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target);
|
||||
|
||||
// This is mostly a legacy command, so it's gonna warn if there's
|
||||
|
Loading…
Reference in New Issue
Block a user