Restructure system tag command

This commit is contained in:
Ske 2020-02-23 00:52:28 +01:00
parent ee3ac44664
commit 4df3be8c3a

View File

@ -50,15 +50,28 @@ namespace PluralKit.Bot
{ {
ctx.CheckSystem(); ctx.CheckSystem();
var newTag = ctx.RemainderOrNull(skipFlags: false); if (ctx.MatchFlag("c", "clear"))
ctx.System.Tag = newTag; {
ctx.System.Tag = null;
if (newTag != null) await _data.SaveSystem(ctx.System);
if (newTag.Length > Limits.MaxSystemTagLength) await ctx.Reply($"{Emojis.Success} System tag cleared.");
throw Errors.SystemNameTooLongError(newTag.Length); } else if (!ctx.HasNext(skipFlags: false))
{
await _data.SaveSystem(ctx.System); if (ctx.System.Tag == null)
await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? $"changed. Member names will now end with `{newTag.SanitizeMentions()}` when proxied" : "cleared")}."); await ctx.Reply($"You currently have no system tag. To set one, type `pk;s tag <tag>`.");
else
await ctx.Reply($"Your current system tag is `{ctx.System.Tag.SanitizeMentions()}`. To change it, type `pk;s tag <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) public async Task Avatar(Context ctx)