public async Task Tag(Context ctx) { ctx.CheckSystem(); var newTag = ctx.RemainderOrNull(); ctx.System.Tag = newTag; if (newTag != null) { if (newTag.Length > Limits.MaxSystemTagLength) { throw Errors.SystemNameTooLongError(newTag.Length); } // Check unproxyable messages *after* changing the tag (so it's seen in the method) but *before* we save to DB (so we can cancel) var unproxyableMembers = await _members.GetUnproxyableMembers(ctx.System); if (unproxyableMembers.Count > 0) { var msg = await ctx.Reply( $"{Emojis.Warn} Changing your system tag to '{newTag.SanitizeMentions()}' will result in the following members being unproxyable, since the tag would bring their name over {Limits.MaxProxyNameLength} characters:\n**{string.Join(", ", unproxyableMembers.Select((m) => m.Name.SanitizeMentions()))}**\nDo you want to continue anyway?"); if (!await ctx.PromptYesNo(msg)) { throw new PKError("Tag change cancelled."); } } } await _systems.Save(ctx.System); await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? "changed" : "cleared")}."); await _proxyCache.InvalidateResultsForSystem(ctx.System); }