Remove 60+ (whew) SanitizeMentions() calls
This commit is contained in:
		| @@ -227,12 +227,12 @@ namespace PluralKit.Bot | ||||
|             if (input.Length == 5) | ||||
|             { | ||||
|                 if (_senderSystem != null) | ||||
|                     return $"Member with ID or name \"{input.SanitizeMentions()}\" not found."; | ||||
|                 return $"Member with ID \"{input.SanitizeMentions()}\" not found."; // Accounts without systems can't query by name | ||||
|                     return $"Member with ID or name \"{input}\" not found."; | ||||
|                 return $"Member with ID \"{input}\" not found."; // Accounts without systems can't query by name | ||||
|             } | ||||
|  | ||||
|             if (_senderSystem != null) | ||||
|                 return $"Member with name \"{input.SanitizeMentions()}\" not found. Note that a member ID is 5 characters long."; | ||||
|                 return $"Member with name \"{input}\" not found. Note that a member ID is 5 characters long."; | ||||
|             return $"Member not found. Note that a member ID is 5 characters long."; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -159,7 +159,7 @@ namespace PluralKit.Bot | ||||
|                 return ctx.Execute<Member>(MemberRandom, m => m.MemberRandom(ctx)); | ||||
|  | ||||
|             ctx.Reply( | ||||
|                 $"{Emojis.Error} Unknown command `{ctx.PeekArgument().SanitizeMentions()}`. For a list of possible commands, see <https://pluralkit.me/commands>."); | ||||
|                 $"{Emojis.Error} Unknown command `{ctx.PeekArgument()}`. For a list of possible commands, see <https://pluralkit.me/commands>."); | ||||
|             return Task.CompletedTask; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -28,7 +28,7 @@ namespace PluralKit.Bot | ||||
|             // Warn if there's already a member by this name | ||||
|             var existingMember = await _data.GetMemberByName(ctx.System, memberName); | ||||
|             if (existingMember != null) { | ||||
|                 var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx).SanitizeMentions()}\" (with ID `{existingMember.Hid}`). Do you want to create another member with the same name?"); | ||||
|                 var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (with ID `{existingMember.Hid}`). Do you want to create another member with the same name?"); | ||||
|                 if (!await ctx.PromptYesNo(msg)) throw new PKError("Member creation cancelled."); | ||||
|             } | ||||
|  | ||||
| @@ -42,7 +42,7 @@ namespace PluralKit.Bot | ||||
|             memberCount++; | ||||
|              | ||||
|             // Send confirmation and space hint | ||||
|             await ctx.Reply($"{Emojis.Success} Member \"{memberName.SanitizeMentions()}\" (`{member.Hid}`) registered! Check out the getting started page for how to get a member up and running: https://pluralkit.me/start#members"); | ||||
|             await ctx.Reply($"{Emojis.Success} Member \"{memberName}\" (`{member.Hid}`) registered! Check out the getting started page for how to get a member up and running: https://pluralkit.me/start#members"); | ||||
|             if (memberName.Contains(" ")) | ||||
|                 await ctx.Reply($"{Emojis.Note} Note that this member's name contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it, or just use the member's 5-character ID (which is `{member.Hid}`)."); | ||||
|             if (memberCount >= Limits.MaxMemberCount) | ||||
|   | ||||
| @@ -62,7 +62,7 @@ namespace PluralKit.Bot | ||||
|             } | ||||
|  | ||||
|             var eb = new DiscordEmbedBuilder() | ||||
|                 .WithTitle($"{target.NameFor(ctx).SanitizeMentions()}'s {field}") | ||||
|                 .WithTitle($"{target.NameFor(ctx)}'s {field}") | ||||
|                 .WithImageUrl(currentValue); | ||||
|             if (target.System == ctx.System?.Id) | ||||
|                 eb.WithDescription($"To clear, use `pk;member {target.Hid} {cmd} clear`."); | ||||
|   | ||||
| @@ -35,7 +35,7 @@ namespace PluralKit.Bot | ||||
|             // Warn if there's already a member by this name | ||||
|             var existingMember = await _data.GetMemberByName(ctx.System, newName); | ||||
|             if (existingMember != null) { | ||||
|                 var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx).SanitizeMentions()}\" (`{existingMember.Hid}`). Do you want to rename this member to that name too?"); | ||||
|                 var msg = await ctx.Reply($"{Emojis.Warn} You already have a member in your system with the name \"{existingMember.NameFor(ctx)}\" (`{existingMember.Hid}`). Do you want to rename this member to that name too?"); | ||||
|                 if (!await ctx.PromptYesNo(msg)) throw new PKError("Member renaming cancelled."); | ||||
|             } | ||||
|  | ||||
| @@ -45,13 +45,13 @@ namespace PluralKit.Bot | ||||
|  | ||||
|             await ctx.Reply($"{Emojis.Success} Member renamed."); | ||||
|             if (newName.Contains(" ")) await ctx.Reply($"{Emojis.Note} Note that this member's name now contains spaces. You will need to surround it with \"double quotes\" when using commands referring to it."); | ||||
|             if (target.DisplayName != null) await ctx.Reply($"{Emojis.Note} Note that this member has a display name set ({target.DisplayName.SanitizeMentions()}), and will be proxied using that name instead."); | ||||
|             if (target.DisplayName != null) await ctx.Reply($"{Emojis.Note} Note that this member has a display name set ({target.DisplayName}), and will be proxied using that name instead."); | ||||
|  | ||||
|             if (ctx.Guild != null) | ||||
|             { | ||||
|                 var memberGuildConfig = await _db.Execute(c => c.QueryOrInsertMemberGuildConfig(ctx.Guild.Id, target.Id)); | ||||
|                 if (memberGuildConfig.DisplayName != null) | ||||
|                     await ctx.Reply($"{Emojis.Note} Note that this member has a server name set ({memberGuildConfig.DisplayName.SanitizeMentions()}) in this server ({ctx.Guild.Name.SanitizeMentions()}), and will be proxied using that name here."); | ||||
|                     await ctx.Reply($"{Emojis.Note} Note that this member has a server name set ({memberGuildConfig.DisplayName}) in this server ({ctx.Guild.Name}), and will be proxied using that name here."); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -82,7 +82,7 @@ namespace PluralKit.Bot | ||||
|                     else | ||||
|                         await ctx.Reply("This member does not have a description set."); | ||||
|                 else if (ctx.MatchFlag("r", "raw")) | ||||
|                     await ctx.Reply($"```\n{target.Description.SanitizeMentions()}\n```"); | ||||
|                     await ctx.Reply($"```\n{target.Description}\n```"); | ||||
|                 else | ||||
|                     await ctx.Reply(embed: new DiscordEmbedBuilder() | ||||
|                         .WithTitle("Member description") | ||||
| @@ -124,7 +124,7 @@ namespace PluralKit.Bot | ||||
|                     else | ||||
|                         await ctx.Reply("This member does not have pronouns set."); | ||||
|                 else | ||||
|                     await ctx.Reply($"**{target.NameFor(ctx).SanitizeMentions()}**'s pronouns are **{target.Pronouns.SanitizeMentions()}**." | ||||
|                     await ctx.Reply($"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**." | ||||
|                         + (ctx.System?.Id == target.System ? $" To clear them, type `pk;member {target.Hid} pronouns -clear`." : "")); | ||||
|             } | ||||
|             else | ||||
| @@ -248,9 +248,9 @@ namespace PluralKit.Bot | ||||
|             if (ctx.Guild != null) | ||||
|             { | ||||
|                 if (memberGuildConfig?.DisplayName != null) | ||||
|                     eb.AddField($"Server Name (in {ctx.Guild.Name.SanitizeMentions()})", $"**{memberGuildConfig.DisplayName}**"); | ||||
|                     eb.AddField($"Server Name (in {ctx.Guild.Name})", $"**{memberGuildConfig.DisplayName}**"); | ||||
|                 else | ||||
|                     eb.AddField($"Server Name (in {ctx.Guild.Name.SanitizeMentions()})", memberGuildConfig?.DisplayName ?? "*(none)*"); | ||||
|                     eb.AddField($"Server Name (in {ctx.Guild.Name})", memberGuildConfig?.DisplayName ?? "*(none)*"); | ||||
|             } | ||||
|  | ||||
|             return eb; | ||||
| @@ -265,7 +265,7 @@ namespace PluralKit.Bot | ||||
|                 { | ||||
|                     var memberGuildConfig = await _db.Execute(c => c.QueryOrInsertMemberGuildConfig(ctx.Guild.Id, target.Id)); | ||||
|                     if (memberGuildConfig.DisplayName != null) | ||||
|                         successStr += $" However, this member has a server name set in this server ({ctx.Guild.Name.SanitizeMentions()}), and will be proxied using that name, \"{memberGuildConfig.DisplayName.SanitizeMentions()}\", here."; | ||||
|                         successStr += $" However, this member has a server name set in this server ({ctx.Guild.Name}), and will be proxied using that name, \"{memberGuildConfig.DisplayName}\", here."; | ||||
|                 } | ||||
|  | ||||
|                 await ctx.Reply(successStr); | ||||
| @@ -277,7 +277,7 @@ namespace PluralKit.Bot | ||||
|                  | ||||
|                 target.DisplayName = null; | ||||
|                 await _data.SaveMember(target); | ||||
|                 await PrintSuccess($"{Emojis.Success} Member display name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx).SanitizeMentions()}\"."); | ||||
|                 await PrintSuccess($"{Emojis.Success} Member display name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\"."); | ||||
|             } | ||||
|             else if (!ctx.HasNext()) | ||||
|             { | ||||
| @@ -295,7 +295,7 @@ namespace PluralKit.Bot | ||||
|                 target.DisplayName = newDisplayName; | ||||
|                 await _data.SaveMember(target); | ||||
|  | ||||
|                 await PrintSuccess($"{Emojis.Success} Member display name changed. This member will now be proxied using the name \"{newDisplayName.SanitizeMentions()}\"."); | ||||
|                 await PrintSuccess($"{Emojis.Success} Member display name changed. This member will now be proxied using the name \"{newDisplayName}\"."); | ||||
|             } | ||||
|         } | ||||
|          | ||||
| @@ -312,9 +312,9 @@ namespace PluralKit.Bot | ||||
|                         new {member = target.Id, guild = ctx.Guild.Id})); | ||||
|  | ||||
|                 if (target.DisplayName != null) | ||||
|                     await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their global display name \"{target.DisplayName.SanitizeMentions()}\" in this server ({ctx.Guild.Name.SanitizeMentions()})."); | ||||
|                     await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their global display name \"{target.DisplayName}\" in this server ({ctx.Guild.Name})."); | ||||
|                 else | ||||
|                     await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx).SanitizeMentions()}\" in this server ({ctx.Guild.Name.SanitizeMentions()})."); | ||||
|                     await ctx.Reply($"{Emojis.Success} Member server name cleared. This member will now be proxied using their member name \"{target.NameFor(ctx)}\" in this server ({ctx.Guild.Name})."); | ||||
|             } | ||||
|             else if (!ctx.HasNext()) | ||||
|             { | ||||
| @@ -334,7 +334,7 @@ namespace PluralKit.Bot | ||||
|                     c.ExecuteAsync("update member_guild set display_name = @newServerName where member = @member and guild = @guild", | ||||
|                         new {member = target.Id, guild = ctx.Guild.Id, newServerName}));     | ||||
|  | ||||
|                 await ctx.Reply($"{Emojis.Success} Member server name changed. This member will now be proxied using the name \"{newServerName.SanitizeMentions()}\" in this server ({ctx.Guild.Name.SanitizeMentions()})."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Member server name changed. This member will now be proxied using the name \"{newServerName}\" in this server ({ctx.Guild.Name})."); | ||||
|             } | ||||
|         } | ||||
|          | ||||
| @@ -416,7 +416,7 @@ namespace PluralKit.Bot | ||||
|  | ||||
|                 if (!ctx.HasNext()) | ||||
|                     throw new PKSyntaxError($"You must pass a privacy level for `{subjectName}` (`public` or `private`)"); | ||||
|                 throw new PKSyntaxError($"Invalid privacy level `{ctx.PopArgument().SanitizeMentions()}` (must be `public` or `private`)."); | ||||
|                 throw new PKSyntaxError($"Invalid privacy level `{ctx.PopArgument()}` (must be `public` or `private`)."); | ||||
|             } | ||||
|              | ||||
|             // See if we have a subject given | ||||
| @@ -455,7 +455,7 @@ namespace PluralKit.Bot | ||||
|                     _ => throw new InvalidOperationException($"Invalid subject/level tuple ({subject}, {newLevel})") | ||||
|                 }; | ||||
|                  | ||||
|                 await ctx.Reply($"{Emojis.Success} {target.NameFor(ctx).SanitizeMentions()}'s {subject.Name()} has been set to **{newLevel.Name()}**. {explanation}"); | ||||
|                 await ctx.Reply($"{Emojis.Success} {target.NameFor(ctx)}'s {subject.Name()} has been set to **{newLevel.Name()}**. {explanation}"); | ||||
|             } | ||||
|             else if (ctx.Match("all") || newValueFromCommand != null) | ||||
|             { | ||||
| @@ -464,14 +464,14 @@ namespace PluralKit.Bot | ||||
|                 await _data.SaveMember(target); | ||||
|                  | ||||
|                 if(newLevel == PrivacyLevel.Private) | ||||
|                     await ctx.Reply($"All {target.NameFor(ctx).SanitizeMentions()}'s privacy settings have been set to **{newLevel.Name()}**. Other accounts will now see nothing on the member card."); | ||||
|                     await ctx.Reply($"All {target.NameFor(ctx)}'s privacy settings have been set to **{newLevel.Name()}**. Other accounts will now see nothing on the member card."); | ||||
|                 else  | ||||
|                     await ctx.Reply($"All {target.NameFor(ctx).SanitizeMentions()}'s privacy settings have been set to **{newLevel.Name()}**. Other accounts will now see everything on the member card."); | ||||
|                     await ctx.Reply($"All {target.NameFor(ctx)}'s privacy settings have been set to **{newLevel.Name()}**. Other accounts will now see everything on the member card."); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 var subjectList = "`name`, `description`, `avatar`, `birthday`, `pronouns`, `metadata`, `visibility`, or `all`"; | ||||
|                 throw new PKSyntaxError($"Invalid privacy subject `{ctx.PopArgument().SanitizeMentions()}` (must be {subjectList})."); | ||||
|                 throw new PKSyntaxError($"Invalid privacy subject `{ctx.PopArgument()}` (must be {subjectList})."); | ||||
|             } | ||||
|              | ||||
|             // Name privacy only works given a display name | ||||
| @@ -488,7 +488,7 @@ namespace PluralKit.Bot | ||||
|             if (ctx.System == null) throw Errors.NoSystemError; | ||||
|             if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError; | ||||
|              | ||||
|             await ctx.Reply($"{Emojis.Warn} Are you sure you want to delete \"{target.NameFor(ctx).SanitizeMentions()}\"? If so, reply to this message with the member's ID (`{target.Hid}`). __***This cannot be undone!***__"); | ||||
|             await ctx.Reply($"{Emojis.Warn} Are you sure you want to delete \"{target.NameFor(ctx)}\"? If so, reply to this message with the member's ID (`{target.Hid}`). __***This cannot be undone!***__"); | ||||
|             if (!await ctx.ConfirmWithReply(target.Hid)) throw Errors.MemberDeleteCancelled; | ||||
|             await _data.DeleteMember(target); | ||||
|             await ctx.Reply($"{Emojis.Success} Member deleted."); | ||||
|   | ||||
| @@ -66,7 +66,7 @@ namespace PluralKit.Bot | ||||
|                     await ctx.Reply("This member does not have any proxy tags."); | ||||
|                 else | ||||
|                 { | ||||
|                     var tags = string.Join("\n", target.ProxyTags.Select(t => $"`{t.ProxyString}`".SanitizeMentions())); | ||||
|                     var tags = string.Join("\n", target.ProxyTags.Select(t => $"`{t.ProxyString}`")); | ||||
|                     await ctx.Reply($"This member's proxy tags are:\n{tags}"); | ||||
|                 } | ||||
|             } | ||||
| @@ -88,7 +88,7 @@ namespace PluralKit.Bot | ||||
|                 target.ProxyTags.Add(tagToAdd); | ||||
|                  | ||||
|                 await _data.SaveMember(target); | ||||
|                 await ctx.Reply($"{Emojis.Success} Added proxy tags `{tagToAdd.ProxyString.SanitizeMentions()}`."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Added proxy tags `{tagToAdd.ProxyString}`."); | ||||
|             } | ||||
|             // Subcommand: "remove" | ||||
|             else if (ctx.Match("remove", "delete")) | ||||
| @@ -105,7 +105,7 @@ namespace PluralKit.Bot | ||||
|                 target.ProxyTags.Remove(tagToRemove); | ||||
|                  | ||||
|                 await _data.SaveMember(target); | ||||
|                 await ctx.Reply($"{Emojis.Success} Removed proxy tags `{tagToRemove.ProxyString.SanitizeMentions()}`."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Removed proxy tags `{tagToRemove.ProxyString}`."); | ||||
|             } | ||||
|             // Subcommand: bare proxy tag given | ||||
|             else | ||||
| @@ -117,7 +117,7 @@ namespace PluralKit.Bot | ||||
|                 // already more than one proxy tag. | ||||
|                 if (target.ProxyTags.Count > 1) | ||||
|                 { | ||||
|                     var msg = await ctx.Reply($"This member already has more than one proxy tag set: {target.ProxyTagsString().SanitizeMentions()}\nDo you want to replace them?"); | ||||
|                     var msg = await ctx.Reply($"This member already has more than one proxy tag set: {target.ProxyTagsString()}\nDo you want to replace them?"); | ||||
|                     if (!await ctx.PromptYesNo(msg)) | ||||
|                         throw Errors.GenericCancelled(); | ||||
|                 } | ||||
| @@ -128,7 +128,7 @@ namespace PluralKit.Bot | ||||
|                 target.ProxyTags = new[] {requestedTag}; | ||||
|                  | ||||
|                 await _data.SaveMember(target); | ||||
|                 await ctx.Reply($"{Emojis.Success} Member proxy tags set to `{requestedTag.ProxyString.SanitizeMentions()}`."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Member proxy tags set to `{requestedTag.ProxyString}`."); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -103,7 +103,7 @@ namespace PluralKit.Bot { | ||||
|             { | ||||
|                 var guildIdStr = ctx.RemainderOrNull() ?? throw new PKSyntaxError("You must pass a server ID or run this command as ."); | ||||
|                 if (!ulong.TryParse(guildIdStr, out var guildId)) | ||||
|                     throw new PKSyntaxError($"Could not parse `{guildIdStr.SanitizeMentions()}` as an ID."); | ||||
|                     throw new PKSyntaxError($"Could not parse `{guildIdStr}` as an ID."); | ||||
|  | ||||
|                 // TODO: will this call break for sharding if you try to request a guild on a different bot instance? | ||||
|                 guild = await ctx.Rest.GetGuildAsync(guildId); | ||||
| @@ -162,7 +162,7 @@ namespace PluralKit.Bot { | ||||
|              | ||||
|             // Generate the output embed | ||||
|             var eb = new DiscordEmbedBuilder() | ||||
|                 .WithTitle($"Permission check for **{guild.Name.SanitizeMentions()}**"); | ||||
|                 .WithTitle($"Permission check for **{guild.Name}**"); | ||||
|  | ||||
|             if (permissionsMissing.Count == 0) | ||||
|             { | ||||
|   | ||||
| @@ -36,7 +36,7 @@ namespace PluralKit.Bot | ||||
|                 .Build(), new {Id = ctx.Guild.Id, LogChannel = channel?.Id})); | ||||
|  | ||||
|             if (channel != null) | ||||
|                 await ctx.Reply($"{Emojis.Success} Proxy logging channel set to #{channel.Name.SanitizeMentions()}."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Proxy logging channel set to #{channel.Name}."); | ||||
|             else | ||||
|                 await ctx.Reply($"{Emojis.Success} Proxy logging channel cleared."); | ||||
|         } | ||||
| @@ -51,7 +51,7 @@ namespace PluralKit.Bot | ||||
|             else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels."); | ||||
|             else while (ctx.HasNext()) | ||||
|             { | ||||
|                 var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument().SanitizeMentions()}\" not found."); | ||||
|                 var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument()}\" not found."); | ||||
|                 if (channel.GuildId != ctx.Guild.Id) throw new PKError($"Channel {ctx.Guild.Id} is not in this server."); | ||||
|                 affectedChannels.Add(channel); | ||||
|             } | ||||
| @@ -85,7 +85,7 @@ namespace PluralKit.Bot | ||||
|             else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels."); | ||||
|             else while (ctx.HasNext()) | ||||
|             { | ||||
|                 var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument().SanitizeMentions()}\" not found."); | ||||
|                 var channel = await ctx.MatchChannel() ?? throw new PKSyntaxError($"Channel \"{ctx.PopArgument()}\" not found."); | ||||
|                 if (channel.GuildId != ctx.Guild.Id) throw new PKError($"Channel {ctx.Guild.Id} is not in this server."); | ||||
|                 affectedChannels.Add(channel); | ||||
|             } | ||||
|   | ||||
| @@ -70,7 +70,7 @@ namespace PluralKit.Bot | ||||
|             if (members.Count == 0) | ||||
|                 await ctx.Reply($"{Emojis.Success} Switch-out registered."); | ||||
|             else | ||||
|                 await ctx.Reply($"{Emojis.Success} Switch registered. Current fronter is now {string.Join(", ", members.Select(m => m.NameFor(ctx))).SanitizeMentions()}."); | ||||
|                 await ctx.Reply($"{Emojis.Success} Switch registered. Current fronter is now {string.Join(", ", members.Select(m => m.NameFor(ctx)))}."); | ||||
|         } | ||||
|          | ||||
|         public async Task SwitchMove(Context ctx) | ||||
| @@ -109,7 +109,7 @@ namespace PluralKit.Bot | ||||
|             var newSwitchDeltaStr = DateTimeFormats.DurationFormat.Format(SystemClock.Instance.GetCurrentInstant() - time.ToInstant()); | ||||
|              | ||||
|             // yeet | ||||
|             var msg = await ctx.Reply($"{Emojis.Warn} This will move the latest switch ({lastSwitchMemberStr.SanitizeMentions()}) from {lastSwitchTimeStr} ({lastSwitchDeltaStr} ago) to {newSwitchTimeStr} ({newSwitchDeltaStr} ago). Is this OK?"); | ||||
|             var msg = await ctx.Reply($"{Emojis.Warn} This will move the latest switch ({lastSwitchMemberStr}) from {lastSwitchTimeStr} ({lastSwitchDeltaStr} ago) to {newSwitchTimeStr} ({newSwitchDeltaStr} ago). Is this OK?"); | ||||
|             if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchMoveCancelled; | ||||
|              | ||||
|             // aaaand *now* we do the move | ||||
| @@ -144,7 +144,7 @@ namespace PluralKit.Bot | ||||
|             if (lastTwoSwitches.Count == 1) | ||||
|             { | ||||
|                 msg = await ctx.Reply( | ||||
|                     $"{Emojis.Warn} This will delete the latest switch ({lastSwitchMemberStr.SanitizeMentions()}, {lastSwitchDeltaStr} ago). You have no other switches logged. Is this okay?"); | ||||
|                     $"{Emojis.Warn} This will delete the latest switch ({lastSwitchMemberStr}, {lastSwitchDeltaStr} ago). You have no other switches logged. Is this okay?"); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @@ -152,7 +152,7 @@ namespace PluralKit.Bot | ||||
|                 var secondSwitchMemberStr = string.Join(", ", await secondSwitchMembers.Select(m => m.NameFor(ctx)).ToListAsync()); | ||||
|                 var secondSwitchDeltaStr = DateTimeFormats.DurationFormat.Format(SystemClock.Instance.GetCurrentInstant() - lastTwoSwitches[1].Timestamp); | ||||
|                 msg = await ctx.Reply( | ||||
|                     $"{Emojis.Warn} This will delete the latest switch ({lastSwitchMemberStr.SanitizeMentions()}, {lastSwitchDeltaStr} ago). The next latest switch is {secondSwitchMemberStr.SanitizeMentions()} ({secondSwitchDeltaStr} ago). Is this okay?"); | ||||
|                     $"{Emojis.Warn} This will delete the latest switch ({lastSwitchMemberStr}, {lastSwitchDeltaStr} ago). The next latest switch is {secondSwitchMemberStr} ({secondSwitchDeltaStr} ago). Is this okay?"); | ||||
|             } | ||||
|  | ||||
|             if (!await ctx.PromptYesNo(msg)) throw Errors.SwitchDeleteCancelled; | ||||
|   | ||||
| @@ -44,7 +44,7 @@ namespace PluralKit.Bot | ||||
|             if (newSystemName == null) | ||||
|             { | ||||
|                 if (ctx.System.Name != null) | ||||
|                     await ctx.Reply($"Your system's name is currently **{ctx.System.Name.SanitizeMentions()}**. Type `pk;system name -clear` to clear it."); | ||||
|                     await ctx.Reply($"Your system's name is currently **{ctx.System.Name}**. Type `pk;system name -clear` to clear it."); | ||||
|                 else | ||||
|                     await ctx.Reply("Your system currently does not have a name. Type `pk;system name <name>` to set one."); | ||||
|                 return; | ||||
| @@ -73,7 +73,7 @@ namespace PluralKit.Bot | ||||
|                 if (ctx.System.Description == null) | ||||
|                     await ctx.Reply("Your system does not have a description set. To set one, type `pk;s description <description>`."); | ||||
|                 else if (ctx.MatchFlag("r", "raw")) | ||||
|                     await ctx.Reply($"```\n{ctx.System.Description.SanitizeMentions()}\n```"); | ||||
|                     await ctx.Reply($"```\n{ctx.System.Description}\n```"); | ||||
|                 else | ||||
|                     await ctx.Reply(embed: new DiscordEmbedBuilder() | ||||
|                         .WithTitle("System description") | ||||
| @@ -104,7 +104,7 @@ namespace PluralKit.Bot | ||||
|                 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`."); | ||||
|                     await ctx.Reply($"Your current system tag is `{ctx.System.Tag}`. To change it, type `pk;s tag <tag>`. To clear it, type `pk;s tag -clear`."); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @@ -114,7 +114,7 @@ namespace PluralKit.Bot | ||||
|                         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."); | ||||
|                 await ctx.Reply($"{Emojis.Success} System tag changed. Member names will now end with `{newTag}` when proxied."); | ||||
|             } | ||||
|         } | ||||
|          | ||||
| @@ -285,7 +285,7 @@ namespace PluralKit.Bot | ||||
|  | ||||
|                 if (!ctx.HasNext()) | ||||
|                     throw new PKSyntaxError($"You must pass a privacy level for `{subject}` (`public` or `private`)"); | ||||
|                 throw new PKSyntaxError($"Invalid privacy level `{ctx.PopArgument().SanitizeMentions()}` (must be `public` or `private`)."); | ||||
|                 throw new PKSyntaxError($"Invalid privacy level `{ctx.PopArgument()}` (must be `public` or `private`)."); | ||||
|             } | ||||
|  | ||||
|             string levelStr, levelExplanation, subjectStr; | ||||
| @@ -320,7 +320,7 @@ namespace PluralKit.Bot | ||||
|  | ||||
|             } | ||||
|             else | ||||
|                 throw new PKSyntaxError($"Invalid privacy subject `{ctx.PopArgument().SanitizeMentions()}` (must be {subjectList})."); | ||||
|                 throw new PKSyntaxError($"Invalid privacy subject `{ctx.PopArgument()}` (must be {subjectList})."); | ||||
|  | ||||
|             await _data.SaveSystem(ctx.System); | ||||
|             if(subjectStr == "all"){ | ||||
|   | ||||
| @@ -44,10 +44,10 @@ namespace PluralKit.Bot | ||||
|         { | ||||
|             var title = new StringBuilder("Members of "); | ||||
|              | ||||
|             if (target.Name != null) title.Append($"{target.Name.SanitizeMentions()} (`{target.Hid}`)"); | ||||
|             if (target.Name != null) title.Append($"{target.Name} (`{target.Hid}`)"); | ||||
|             else title.Append($"`{target.Hid}`"); | ||||
|   | ||||
|             if (opts.Filter != null) title.Append($" matching **{opts.Filter.SanitizeMentions()}**"); | ||||
|             if (opts.Filter != null) title.Append($" matching **{opts.Filter}**"); | ||||
|              | ||||
|             return title.ToString(); | ||||
|         } | ||||
|   | ||||
| @@ -46,15 +46,15 @@ namespace PluralKit.Bot { | ||||
|         public static PKError MemberLimitReachedError => new PKError($"System has reached the maximum number of members ({Limits.MaxMemberCount}). Please delete unused members first in order to create new ones."); | ||||
|         public static PKError NoMembersError => new PKError("Your system has no members! Please create at least one member before using this command."); | ||||
|  | ||||
|         public static PKError InvalidColorError(string color) => new PKError($"\"{color.SanitizeMentions()}\" is not a valid color. Color must be in 6-digit RGB hex format (eg. #ff0000)."); | ||||
|         public static PKError BirthdayParseError(string birthday) => new PKError($"\"{birthday.SanitizeMentions()}\" could not be parsed as a valid date. Try a format like \"2016-12-24\" or \"May 3 1996\"."); | ||||
|         public static PKError InvalidColorError(string color) => new PKError($"\"{color}\" is not a valid color. Color must be in 6-digit RGB hex format (eg. #ff0000)."); | ||||
|         public static PKError BirthdayParseError(string birthday) => new PKError($"\"{birthday}\" could not be parsed as a valid date. Try a format like \"2016-12-24\" or \"May 3 1996\"."); | ||||
|         public static PKError ProxyMustHaveText => new PKSyntaxError("Example proxy message must contain the string 'text'."); | ||||
|         public static PKError ProxyMultipleText => new PKSyntaxError("Example proxy message must contain the string 'text' exactly once."); | ||||
|          | ||||
|         public static PKError MemberDeleteCancelled => new PKError($"Member deletion cancelled. Stay safe! {Emojis.ThumbsUp}"); | ||||
|         public static PKError AvatarServerError(HttpStatusCode statusCode) => new PKError($"Server responded with status code {(int) statusCode}, are you sure your link is working?"); | ||||
|         public static PKError AvatarFileSizeLimit(long size) => new PKError($"File size too large ({size.Bytes().ToString("#.#")} > {Limits.AvatarFileSizeLimit.Bytes().ToString("#.#")}), try shrinking or compressing the image."); | ||||
|         public static PKError AvatarNotAnImage(string mimeType) => new PKError($"The given link does not point to an image{(mimeType != null ? $" ({mimeType.SanitizeMentions()})" : "")}. Make sure you're using a direct link (ending in .jpg, .png, .gif)."); | ||||
|         public static PKError AvatarNotAnImage(string mimeType) => new PKError($"The given link does not point to an image{(mimeType != null ? $" ({mimeType})" : "")}. Make sure you're using a direct link (ending in .jpg, .png, .gif)."); | ||||
|         public static PKError AvatarDimensionsTooLarge(int width, int height) => new PKError($"Image too large ({width}x{height} > {Limits.AvatarDimensionLimit}x{Limits.AvatarDimensionLimit}), try resizing the image."); | ||||
|         public static PKError AvatarInvalid => new PKError($"Could not read image file - perhaps it's corrupted or the wrong format. Try a different image."); | ||||
|         public static PKError UserHasNoAvatar => new PKError("The given user has no avatar set."); | ||||
| @@ -71,43 +71,43 @@ namespace PluralKit.Bot { | ||||
|         public static PKError SameSwitch(ICollection<PKMember> members, LookupContext ctx) | ||||
|         { | ||||
|             if (members.Count == 0) return new PKError("There's already no one in front."); | ||||
|             if (members.Count == 1) return new PKError($"Member {members.First().NameFor(ctx).SanitizeMentions()} is already fronting."); | ||||
|             return new PKError($"Members {string.Join(", ", members.Select(m => m.NameFor(ctx).SanitizeMentions()))} are already fronting."); | ||||
|             if (members.Count == 1) return new PKError($"Member {members.First().NameFor(ctx)} is already fronting."); | ||||
|             return new PKError($"Members {string.Join(", ", members.Select(m => m.NameFor(ctx)))} are already fronting."); | ||||
|         } | ||||
|  | ||||
|         public static PKError DuplicateSwitchMembers => new PKError("Duplicate members in member list."); | ||||
|         public static PKError SwitchMemberNotInSystem => new PKError("One or more switch members aren't in your own system."); | ||||
|  | ||||
|         public static PKError InvalidDateTime(string str) => new PKError($"Could not parse '{str.SanitizeMentions()}' as a valid date/time. Try using a syntax such as \"May 21, 12:30 PM\" or \"3d12h\" (ie. 3 days, 12 hours ago)."); | ||||
|         public static PKError InvalidDateTime(string str) => new PKError($"Could not parse '{str}' as a valid date/time. Try using a syntax such as \"May 21, 12:30 PM\" or \"3d12h\" (ie. 3 days, 12 hours ago)."); | ||||
|         public static PKError SwitchTimeInFuture => new PKError("Can't move switch to a time in the future."); | ||||
|         public static PKError NoRegisteredSwitches => new PKError("There are no registered switches for this system."); | ||||
|  | ||||
|         public static PKError SwitchMoveBeforeSecondLast(ZonedDateTime time) => new PKError($"Can't move switch to before last switch time ({DateTimeFormats.ZonedDateTimeFormat.Format(time)}), as it would cause conflicts."); | ||||
|         public static PKError SwitchMoveCancelled => new PKError("Switch move cancelled."); | ||||
|         public static PKError SwitchDeleteCancelled => new PKError("Switch deletion cancelled."); | ||||
|         public static PKError TimezoneParseError(string timezone) => new PKError($"Could not parse timezone offset {timezone.SanitizeMentions()}. Offset must be a value like 'UTC+5' or 'GMT-4:30'."); | ||||
|         public static PKError TimezoneParseError(string timezone) => new PKError($"Could not parse timezone offset {timezone}. Offset must be a value like 'UTC+5' or 'GMT-4:30'."); | ||||
|  | ||||
|         public static PKError InvalidTimeZone(string zoneStr) => new PKError($"Invalid time zone ID '{zoneStr.SanitizeMentions()}'. To find your time zone ID, use the following website: <https://xske.github.io/tz>"); | ||||
|         public static PKError InvalidTimeZone(string zoneStr) => new PKError($"Invalid time zone ID '{zoneStr}'. To find your time zone ID, use the following website: <https://xske.github.io/tz>"); | ||||
|         public static PKError TimezoneChangeCancelled => new PKError("Time zone change cancelled."); | ||||
|         public static PKError AmbiguousTimeZone(string zoneStr, int count) => new PKError($"The time zone query '{zoneStr.SanitizeMentions()}' resulted in **{count}** different time zone regions. Try being more specific - e.g. pass an exact time zone specifier from the following website: <https://xske.github.io/tz>"); | ||||
|         public static PKError AmbiguousTimeZone(string zoneStr, int count) => new PKError($"The time zone query '{zoneStr}' resulted in **{count}** different time zone regions. Try being more specific - e.g. pass an exact time zone specifier from the following website: <https://xske.github.io/tz>"); | ||||
|         public static PKError NoImportFilePassed => new PKError("You must either pass an URL to a file as a command parameter, or as an attachment to the message containing the command."); | ||||
|         public static PKError InvalidImportFile => new PKError("Imported data file invalid. Make sure this is a .json file directly exported from PluralKit or Tupperbox."); | ||||
|         public static PKError ImportCancelled => new PKError("Import cancelled."); | ||||
|         public static PKError MessageNotFound(ulong id) => new PKError($"Message with ID '{id}' not found. Are you sure it's a message proxied by PluralKit?"); | ||||
|          | ||||
|         public static PKError DurationParseError(string durationStr) => new PKError($"Could not parse '{durationStr.SanitizeMentions()}' as a valid duration. Try a format such as `30d`, `1d3h` or `20m30s`."); | ||||
|         public static PKError DurationParseError(string durationStr) => new PKError($"Could not parse '{durationStr}' as a valid duration. Try a format such as `30d`, `1d3h` or `20m30s`."); | ||||
|         public static PKError FrontPercentTimeInFuture => new PKError("Cannot get the front percent between now and a time in the future."); | ||||
|  | ||||
|         public static PKError GuildNotFound(ulong guildId) => new PKError($"Guild with ID {guildId} not found."); | ||||
|  | ||||
|         public static PKError DisplayNameTooLong(string displayName, int maxLength) => new PKError( | ||||
|             $"Display name too long ({displayName.Length} > {maxLength} characters). Use a shorter display name, or shorten your system tag."); | ||||
|         public static PKError ProxyNameTooShort(string name) => new PKError($"The webhook's name, `{name.SanitizeMentions()}`, is shorter than two characters, and thus cannot be proxied. Please change the member name or use a longer system tag."); | ||||
|         public static PKError ProxyNameTooLong(string name) => new PKError($"The webhook's name, {name.SanitizeMentions()}, is too long ({name.Length} > {Limits.MaxProxyNameLength} characters), and thus cannot be proxied. Please change the member name, display name or server display name, or use a shorter system tag."); | ||||
|         public static PKError ProxyNameTooShort(string name) => new PKError($"The webhook's name, `{name}`, is shorter than two characters, and thus cannot be proxied. Please change the member name or use a longer system tag."); | ||||
|         public static PKError ProxyNameTooLong(string name) => new PKError($"The webhook's name, {name}, is too long ({name.Length} > {Limits.MaxProxyNameLength} characters), and thus cannot be proxied. Please change the member name, display name or server display name, or use a shorter system tag."); | ||||
|  | ||||
|         public static PKError ProxyTagAlreadyExists(ProxyTag tagToAdd, PKMember member) => new PKError($"That member already has the proxy tag `{tagToAdd.ProxyString.SanitizeMentions()}`. The member currently has these tags: {member.ProxyTagsString().SanitizeMentions()}"); | ||||
|         public static PKError ProxyTagDoesNotExist(ProxyTag tagToRemove, PKMember member) => new PKError($"That member does not have the proxy tag `{tagToRemove.ProxyString.SanitizeMentions()}`. The member currently has these tags: {member.ProxyTagsString().SanitizeMentions()}"); | ||||
|         public static PKError LegacyAlreadyHasProxyTag(ProxyTag requested, PKMember member) => new PKError($"This member already has more than one proxy tag set: {member.ProxyTagsString().SanitizeMentions()}\nConsider using the `pk;member {member.Hid} proxy add {requested.ProxyString.SanitizeMentions()}` command instead."); | ||||
|         public static PKError ProxyTagAlreadyExists(ProxyTag tagToAdd, PKMember member) => new PKError($"That member already has the proxy tag `{tagToAdd.ProxyString}`. The member currently has these tags: {member.ProxyTagsString()}"); | ||||
|         public static PKError ProxyTagDoesNotExist(ProxyTag tagToRemove, PKMember member) => new PKError($"That member does not have the proxy tag `{tagToRemove.ProxyString}`. The member currently has these tags: {member.ProxyTagsString()}"); | ||||
|         public static PKError LegacyAlreadyHasProxyTag(ProxyTag requested, PKMember member) => new PKError($"This member already has more than one proxy tag set: {member.ProxyTagsString()}\nConsider using the `pk;member {member.Hid} proxy add {requested.ProxyString}` command instead."); | ||||
|         public static PKError EmptyProxyTags(PKMember member) => new PKError($"The example proxy `text` is equivalent to having no proxy tags at all, since there are no symbols or brackets on either end. If you'd like to clear your proxy tags, use `pk;member {member.Hid} proxy clear`."); | ||||
|  | ||||
|         public static PKError GenericCancelled() => new PKError("Operation cancelled."); | ||||
|   | ||||
| @@ -19,13 +19,13 @@ namespace PluralKit.Bot | ||||
|             { | ||||
|                 if (m.HasProxyTags) | ||||
|                 { | ||||
|                     var proxyTagsString = m.ProxyTagsString().SanitizeMentions(); | ||||
|                     var proxyTagsString = m.ProxyTagsString(); | ||||
|                     if (proxyTagsString.Length > 100) // arbitrary threshold for now, tweak? | ||||
|                         proxyTagsString = "tags too long, see member card"; | ||||
|                     return $"[`{m.Hid}`] **{m.NameFor(ctx).SanitizeMentions()}** *({proxyTagsString})*"; | ||||
|                     return $"[`{m.Hid}`] **{m.NameFor(ctx)}** *({proxyTagsString})*"; | ||||
|                 } | ||||
|  | ||||
|                 return $"[`{m.Hid}`] **{m.NameFor(ctx).SanitizeMentions()}**"; | ||||
|                 return $"[`{m.Hid}`] **{m.NameFor(ctx)}**"; | ||||
|             } | ||||
|  | ||||
|             var buf = new StringBuilder(); | ||||
|   | ||||
| @@ -44,12 +44,6 @@ namespace PluralKit.Bot | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         public static string SanitizeMentions(this string input) => | ||||
|             Regex.Replace(Regex.Replace(input, "<@[!&]?(\\d{17,19})>", "<\u200B@$1>"), "@(everyone|here)", "@\u200B$1"); | ||||
|  | ||||
|         public static string SanitizeEveryone(this string input) => | ||||
|             Regex.Replace(input, "@(everyone|here)", "@\u200B$1"); | ||||
|  | ||||
|         public static string EscapeMarkdown(this string input) | ||||
|         { | ||||
|             Regex pattern = new Regex(@"[*_~>`(||)\\]", RegexOptions.Multiline); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user