From d2189dea73b93687c2f7b4de967bbb4c07c03fab Mon Sep 17 00:00:00 2001 From: rladenson Date: Sun, 5 Jan 2025 05:59:10 -0700 Subject: [PATCH] feat: show appropriate warnings when setting tag --- PluralKit.Bot/Commands/SystemEdit.cs | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index e7e4d6b4..c5d8820a 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -10,6 +10,7 @@ using Myriad.Types; using Newtonsoft.Json; using PluralKit.Core; +using SqlKata.Compilers; namespace PluralKit.Bot; @@ -317,7 +318,19 @@ public class SystemEdit { await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Tag = null }); - await ctx.Reply($"{Emojis.Success} System tag cleared."); + var replyStr = $"{Emojis.Success} System tag cleared."; + + if (ctx.Guild != null) + { + var servertag = (await ctx.Repository.GetSystemGuild(ctx.Guild.Id, target.Id)).Tag; + if (servertag is not null) + replyStr += $"\n{Emojis.Note} You have a server tag set in this server ({servertag}) so it will still be shown on proxies."; + + else if (ctx.GuildConfig.RequireSystemTag) + replyStr += $"\n{Emojis.Warn} This server requires a tag in order to proxy. If you do not add a new tag you will not be able to proxy in this server."; + } + + await ctx.Reply(replyStr); } else { @@ -328,8 +341,24 @@ public class SystemEdit await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { Tag = newTag }); - await ctx.Reply( - $"{Emojis.Success} System tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters). Member names will now have the tag {newTag.AsCode()} when proxied.\n\nTo check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`."); + var replyStr = $"{Emojis.Success} System tag changed (using {newTag.Length}/{Limits.MaxSystemTagLength} characters)."; + if (ctx.Config.NameFormat is null || ctx.Config.NameFormat.Contains("{tag}")) + replyStr += $"Member names will now have the tag {newTag.AsCode()} when proxied.\n{Emojis.Note}To check or change where your tag appears in your name use the command `{ctx.DefaultPrefix}cfg name format`."; + else + replyStr += $"\n{Emojis.Warn} You do not have a designated place for a tag in your name format so it **will not be put in proxy names**. To change this type `{ctx.DefaultPrefix}cfg name format`."; + if (ctx.Guild != null) + { + var guildSettings = await ctx.Repository.GetSystemGuild(ctx.Guild.Id, target.Id); + + if (guildSettings.Tag is not null) + replyStr += $"\n{Emojis.Note} Note that you have a server tag set ({guildSettings.Tag}) and it will be shown in proxies instead."; + if (!guildSettings.TagEnabled) + replyStr += $"\n{Emojis.Note} Note that your tag is disabled in this server and will not be shown in proxies. To change this type `{ctx.DefaultPrefix}system servertag enable`."; + if (guildSettings.NameFormat is not null && !guildSettings.NameFormat.Contains("{tag}")) + replyStr += $"\n{Emojis.Note} You do not have a designated place for a tag in your server name format so it **will not be put in proxy names**. To change this type `{ctx.DefaultPrefix}cfg server name format`."; + } + + await ctx.Reply(replyStr); } }