From 4df3be8c3a31ed31e10b2e7259d5c1e8b0aa96d7 Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 23 Feb 2020 00:52:28 +0100 Subject: [PATCH] Restructure system tag command --- PluralKit.Bot/Commands/SystemEdit.cs | 31 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 4f942314..e341d50d 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -50,15 +50,28 @@ namespace PluralKit.Bot { ctx.CheckSystem(); - var newTag = ctx.RemainderOrNull(skipFlags: false); - ctx.System.Tag = newTag; - - if (newTag != null) - if (newTag.Length > Limits.MaxSystemTagLength) - throw Errors.SystemNameTooLongError(newTag.Length); - - await _data.SaveSystem(ctx.System); - await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? $"changed. Member names will now end with `{newTag.SanitizeMentions()}` when proxied" : "cleared")}."); + if (ctx.MatchFlag("c", "clear")) + { + ctx.System.Tag = null; + await _data.SaveSystem(ctx.System); + await ctx.Reply($"{Emojis.Success} System tag cleared."); + } else if (!ctx.HasNext(skipFlags: false)) + { + if (ctx.System.Tag == null) + await ctx.Reply($"You currently have no system tag. To set one, type `pk;s tag `."); + else + await ctx.Reply($"Your current system tag is `{ctx.System.Tag.SanitizeMentions()}`. To change it, type `pk;s tag `. To clear it, type `pk;s tag -clear`."); + } + else + { + var newTag = ctx.RemainderOrNull(skipFlags: false); + if (newTag != null) + if (newTag.Length > Limits.MaxSystemTagLength) + throw Errors.SystemNameTooLongError(newTag.Length); + ctx.System.Tag = newTag; + await _data.SaveSystem(ctx.System); + await ctx.Reply($"{Emojis.Success} System tag changed. Member names will now end with `{newTag.SanitizeMentions()}` when proxied."); + } } public async Task Avatar(Context ctx)