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();
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 <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); var newTag = ctx.RemainderOrNull(skipFlags: false);
ctx.System.Tag = newTag;
if (newTag != null) if (newTag != null)
if (newTag.Length > Limits.MaxSystemTagLength) if (newTag.Length > Limits.MaxSystemTagLength)
throw Errors.SystemNameTooLongError(newTag.Length); throw Errors.SystemNameTooLongError(newTag.Length);
ctx.System.Tag = newTag;
await _data.SaveSystem(ctx.System); 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")}."); 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)