From 5334975ab7defe490be2283cc379185b7eda68b8 Mon Sep 17 00:00:00 2001 From: Ske Date: Mon, 3 Feb 2020 15:11:35 +0100 Subject: [PATCH] PROPERLY handle example proxy "text" --- PluralKit.Bot/Commands/MemberProxy.cs | 7 +++++-- PluralKit.Bot/Errors.cs | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Commands/MemberProxy.cs b/PluralKit.Bot/Commands/MemberProxy.cs index fd60ea23..7ef64f51 100644 --- a/PluralKit.Bot/Commands/MemberProxy.cs +++ b/PluralKit.Bot/Commands/MemberProxy.cs @@ -45,7 +45,7 @@ namespace PluralKit.Bot.Commands // "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.Remainder().Equals("text", StringComparison.InvariantCultureIgnoreCase)) + if (!ctx.HasNext() || ctx.Match("clear", "purge", "clean", "removeall")) { // If we already have multiple tags, this would clear everything, so prompt that if (target.ProxyTags.Count > 1) @@ -67,6 +67,7 @@ namespace PluralKit.Bot.Commands if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`)."); var tagToAdd = ParseProxyTags(ctx.RemainderOrNull()); + if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target); if (target.ProxyTags.Contains(tagToAdd)) throw Errors.ProxyTagAlreadyExists(tagToAdd, target); @@ -86,6 +87,7 @@ namespace PluralKit.Bot.Commands if (!ctx.HasNext()) throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`)."); var tagToRemove = ParseProxyTags(ctx.RemainderOrNull()); + if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target); if (!target.ProxyTags.Contains(tagToRemove)) throw Errors.ProxyTagDoesNotExist(tagToRemove, target); @@ -102,7 +104,8 @@ namespace PluralKit.Bot.Commands if (!ctx.HasNext()) throw new PKSyntaxError("You must pass an example proxy to set (eg. `[text]` or `J:text`)."); var requestedTag = ParseProxyTags(ctx.RemainderOrNull()); - + if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target); + // This is mostly a legacy command, so it's gonna error out if there's // already more than one proxy tag. if (target.ProxyTags.Count > 1) diff --git a/PluralKit.Bot/Errors.cs b/PluralKit.Bot/Errors.cs index c70acdaa..40ea85a4 100644 --- a/PluralKit.Bot/Errors.cs +++ b/PluralKit.Bot/Errors.cs @@ -86,6 +86,7 @@ namespace PluralKit.Bot { public static PKError ProxyTagAlreadyExists(ProxyTag tagToAdd, PKMember member) => new PKError($"That member already has the proxy tag `{tagToAdd.ProxyString.SanitizeMentions()}`. The member currently has these tags: {member.ProxyTagsString().SanitizeMentions()}"); public static PKError ProxyTagDoesNotExist(ProxyTag tagToRemove, PKMember member) => new PKError($"That member does not have the proxy tag `{tagToRemove.ProxyString.SanitizeMentions()}`. The member currently has these tags: {member.ProxyTagsString().SanitizeMentions()}"); public static PKError LegacyAlreadyHasProxyTag(ProxyTag requested, PKMember member) => new PKError($"This member already has more than one proxy tag set: {member.ProxyTagsString().SanitizeMentions()}\nConsider using the `pk;member {member.Hid} proxy add {requested.ProxyString.SanitizeMentions()}` command instead."); + public static PKError EmptyProxyTags(PKMember member) => new PKError($"The example proxy `text` is equivalent to having no proxy tags at all, since there are no symbols or brackets on either end. If you'd like to clear your proxy tags, use `pk;member {member.Hid} proxy clear`."); public static PKError GenericCancelled() => new PKError("Operation cancelled.");