From 49954e32b489ed938efa3f79b177692ab6e06dc3 Mon Sep 17 00:00:00 2001 From: rladenson Date: Tue, 27 Aug 2024 13:32:23 -0600 Subject: [PATCH] feat: Added -plaintext tag alongside -raw --- .../Context/ContextArgumentsExt.cs | 15 +- PluralKit.Bot/Commands/Groups.cs | 101 ++++++---- PluralKit.Bot/Commands/MemberEdit.cs | 125 ++++++++---- PluralKit.Bot/Commands/Message.cs | 37 ++-- PluralKit.Bot/Commands/SystemEdit.cs | 183 +++++++++++------- 5 files changed, 299 insertions(+), 162 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs index 9a93440b..db485cf9 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs @@ -91,8 +91,19 @@ public static class ContextArgumentsExt public static bool MatchClear(this Context ctx) => ctx.Match("clear", "reset", "default") || ctx.MatchFlag("c", "clear"); - public static bool MatchRaw(this Context ctx) => - ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw"); + public enum ReplyFormat + { + Standard, + Raw, + Plaintext + } + + public static ReplyFormat MatchFormat(this Context ctx) + { + if (ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw")) return ReplyFormat.Raw; + if (ctx.Match("pt", "plaintext") || ctx.MatchFlag("pt", "plaintext")) return ReplyFormat.Plaintext; + return ReplyFormat.Standard; + } public static bool MatchToggle(this Context ctx, bool? defaultValue = null) { diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index d2f421c7..5701a527 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -7,6 +7,7 @@ using Myriad.Types; using Newtonsoft.Json.Linq; using PluralKit.Core; +using static PluralKit.Bot.ContextArgumentsExt; namespace PluralKit.Bot; @@ -132,40 +133,45 @@ public class Groups // No perms check, display name isn't covered by member privacy - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.DisplayName == null) + { await ctx.Reply(noDisplayNameSetMessage); - else - await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.DisplayName); return; } if (!ctx.HasNext(false)) { - if (target.DisplayName == null) - { - await ctx.Reply(noDisplayNameSetMessage); - } - else - { - var eb = new EmbedBuilder() - .Field(new Embed.Field("Name", target.Name)) - .Field(new Embed.Field("Display Name", target.DisplayName)); + var eb = new EmbedBuilder() + .Field(new Embed.Field("Name", target.Name)) + .Field(new Embed.Field("Display Name", target.DisplayName)); - var reference = target.Reference(ctx); + var reference = target.Reference(ctx); - if (ctx.System?.Id == target.System) - eb.Description( - $"To change display name, type `pk;group {reference} displayname `.\n" - + $"To clear it, type `pk;group {reference} displayname -clear`.\n" - + $"To print the raw display name, type `pk;group {reference} displayname -raw`."); + if (ctx.System?.Id == target.System) + eb.Description( + $"To change display name, type `pk;group {reference} displayname `.\n" + + $"To clear it, type `pk;group {reference} displayname -clear`.\n" + + $"To print the raw display name, type `pk;group {reference} displayname -raw`."); - if (ctx.System?.Id == target.System) - eb.Footer(new Embed.EmbedFooter($"Using {target.DisplayName.Length}/{Limits.MaxGroupNameLength} characters.")); + if (ctx.System?.Id == target.System) + eb.Footer(new Embed.EmbedFooter($"Using {target.DisplayName.Length}/{Limits.MaxGroupNameLength} characters.")); - await ctx.Reply(embed: eb.Build()); - } + await ctx.Reply(embed: eb.Build()); return; } @@ -201,30 +207,39 @@ public class Groups noDescriptionSetMessage += $" To set one, type `pk;group {target.Reference(ctx)} description `."; - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Description == null) + { await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Description); return; } if (!ctx.HasNext(false)) { - if (target.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply(embed: new EmbedBuilder() - .Title("Group description") - .Description(target.Description) - .Field(new Embed.Field("\u200B", - $"To print the description with formatting, type `pk;group {target.Reference(ctx)} description -raw`." - + (ctx.System?.Id == target.System - ? $" To clear it, type `pk;group {target.Reference(ctx)} description -clear`." - : "") - + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) - .Build()); + await ctx.Reply(embed: new EmbedBuilder() + .Title("Group description") + .Description(target.Description) + .Field(new Embed.Field("\u200B", + $"To print the description with formatting, type `pk;group {target.Reference(ctx)} description -raw`." + + (ctx.System?.Id == target.System + ? $" To clear it, type `pk;group {target.Reference(ctx)} description -clear`." + : "") + + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) + .Build()); return; } @@ -385,7 +400,7 @@ public class Groups public async Task GroupColor(Context ctx, PKGroup target) { var isOwnSystem = ctx.System?.Id == target.System; - var matchedRaw = ctx.MatchRaw(); + var matchedFormat = ctx.MatchFormat(); var matchedClear = ctx.MatchClear(); if (!isOwnSystem || !(ctx.HasNext() || matchedClear)) @@ -393,8 +408,10 @@ public class Groups if (target.Color == null) await ctx.Reply( "This group does not have a color set." + (isOwnSystem ? $" To set one, type `pk;group {target.Reference(ctx)} color `." : "")); - else if (matchedRaw) + else if (matchedFormat == ReplyFormat.Raw) await ctx.Reply("```\n#" + target.Color + "\n```"); + else if (matchedFormat == ReplyFormat.Plaintext) + await ctx.Reply(target.Color); else await ctx.Reply(embed: new EmbedBuilder() .Title("Group color") diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index 84afc443..1e623f4a 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -7,6 +7,7 @@ using NodaTime; using NodaTime.Extensions; using PluralKit.Core; +using static PluralKit.Bot.ContextArgumentsExt; namespace PluralKit.Bot; @@ -70,30 +71,39 @@ public class MemberEdit noDescriptionSetMessage += $" To set one, type `pk;member {target.Reference(ctx)} description `."; - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Description == null) + { await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Description); return; } if (!ctx.HasNext(false)) { - if (target.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply(embed: new EmbedBuilder() - .Title("Member description") - .Description(target.Description) - .Field(new Embed.Field("\u200B", - $"To print the description with formatting, type `pk;member {target.Reference(ctx)} description -raw`." - + (ctx.System?.Id == target.System - ? $" To clear it, type `pk;member {target.Reference(ctx)} description -clear`." - : "") - + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) - .Build()); + await ctx.Reply(embed: new EmbedBuilder() + .Title("Member description") + .Description(target.Description) + .Field(new Embed.Field("\u200B", + $"To print the description with formatting, type `pk;member {target.Reference(ctx)} description -raw`." + + (ctx.System?.Id == target.System + ? $" To clear it, type `pk;member {target.Reference(ctx)} description -clear`." + : "") + + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) + .Build()); return; } @@ -126,26 +136,35 @@ public class MemberEdit ctx.CheckSystemPrivacy(target.System, target.PronounPrivacy); - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Pronouns == null) + { await ctx.Reply(noPronounsSetMessage); - else - await ctx.Reply($"```\n{target.Pronouns}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.Pronouns}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Pronouns); return; } if (!ctx.HasNext(false)) { - if (target.Pronouns == null) - await ctx.Reply(noPronounsSetMessage); - else - await ctx.Reply( - $"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;member {target.Reference(ctx)} pronouns -raw`." - + (ctx.System?.Id == target.System - ? $" To clear them, type `pk;member {target.Reference(ctx)} pronouns -clear`." - : "") - + $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters."); + await ctx.Reply( + $"**{target.NameFor(ctx)}**'s pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;member {target.Reference(ctx)} pronouns -raw`." + + (ctx.System?.Id == target.System + ? $" To clear them, type `pk;member {target.Reference(ctx)} pronouns -clear`." + : "") + + $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters."); return; } @@ -232,7 +251,7 @@ public class MemberEdit public async Task Color(Context ctx, PKMember target) { var isOwnSystem = ctx.System?.Id == target.System; - var matchedRaw = ctx.MatchRaw(); + var matchedFormat = ctx.MatchFormat(); var matchedClear = ctx.MatchClear(); if (!isOwnSystem || !(ctx.HasNext() || matchedClear)) @@ -240,8 +259,10 @@ public class MemberEdit if (target.Color == null) await ctx.Reply( "This member does not have a color set." + (isOwnSystem ? $" To set one, type `pk;member {target.Reference(ctx)} color `." : "")); - else if (matchedRaw) + else if (matchedFormat == ReplyFormat.Raw) await ctx.Reply("```\n#" + target.Color + "\n```"); + else if (matchedFormat == ReplyFormat.Plaintext) + await ctx.Reply(target.Color); else await ctx.Reply(embed: new EmbedBuilder() .Title("Member color") @@ -388,12 +409,24 @@ public class MemberEdit // No perms check, display name isn't covered by member privacy - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if what's next is "raw"/"plaintext" we need to check for null + if (format != ReplyFormat.Standard) if (target.DisplayName == null) + { await ctx.Reply(noDisplayNameSetMessage); - else - await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.DisplayName); return; } @@ -450,12 +483,24 @@ public class MemberEdit // No perms check, display name isn't covered by member privacy var memberGuildConfig = await ctx.Repository.GetMemberGuild(ctx.Guild.Id, target.Id); - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if what's next is "raw"/"plaintext" we need to check for null + if (format != ReplyFormat.Standard) if (memberGuildConfig.DisplayName == null) + { await ctx.Reply(noServerNameSetMessage); - else - await ctx.Reply($"```\n{memberGuildConfig.DisplayName}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{memberGuildConfig.DisplayName}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(memberGuildConfig.DisplayName); return; } diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index b45639d7..e6eabebb 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -352,7 +352,9 @@ public class ProxiedMessage else if (!await ctx.CheckPermissionsInGuildChannel(channel, PermissionSet.ViewChannel)) showContent = false; - if (ctx.MatchRaw()) + var format = ctx.MatchFormat(); + + if (format != ContextArgumentsExt.ReplyFormat.Standard) { var discordMessage = await _rest.GetMessageOrNull(message.Message.Channel, message.Message.Mid); if (discordMessage == null || !showContent) @@ -365,21 +367,30 @@ public class ProxiedMessage return; } - await ctx.Reply($"```{content}```"); - - if (Regex.IsMatch(content, "```.*```", RegexOptions.Singleline)) + if (format == ContextArgumentsExt.ReplyFormat.Raw) { - var stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); - await ctx.Rest.CreateMessage( - ctx.Channel.Id, - new MessageRequest - { - Content = $"{Emojis.Warn} Message contains codeblocks, raw source sent as an attachment." - }, - new[] { new MultipartFile("message.txt", stream, null, null, null) }); + await ctx.Reply($"```{content}```"); + + if (Regex.IsMatch(content, "```.*```", RegexOptions.Singleline)) + { + var stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); + await ctx.Rest.CreateMessage( + ctx.Channel.Id, + new MessageRequest + { + Content = $"{Emojis.Warn} Message contains codeblocks, raw source sent as an attachment." + }, + new[] { new MultipartFile("message.txt", stream, null, null, null) }); + } + return; + } + + if (format == ContextArgumentsExt.ReplyFormat.Plaintext) + { + await ctx.Reply(content); + return; } - return; } if (isDelete) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index a3bcaa64..28e00324 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 static PluralKit.Bot.ContextArgumentsExt; namespace PluralKit.Bot; @@ -37,24 +38,33 @@ public class SystemEdit if (isOwnSystem) noNameSetMessage += " Type `pk;system name ` to set one."; - if (ctx.MatchRaw()) - { - if (target.Name != null) - await ctx.Reply($"```\n{target.Name}\n```"); - else + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) + if (target.Name == null) + { await ctx.Reply(noNameSetMessage); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"` ``\n{target.Name}\n` ``"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Name); return; } if (!ctx.HasNext(false)) { - if (target.Name != null) - await ctx.Reply( - $"{(isOwnSystem ? "Your" : "This")} system's name is currently **{target.Name}**." - + (isOwnSystem ? " Type `pk;system name -clear` to clear it." : "") - + $" Using {target.Name.Length}/{Limits.MaxSystemNameLength} characters."); - else - await ctx.Reply(noNameSetMessage); + await ctx.Reply( + $"{(isOwnSystem ? "Your" : "This")} system's name is currently **{target.Name}**." + + (isOwnSystem ? " Type `pk;system name -clear` to clear it." : "") + + $" Using {target.Name.Length}/{Limits.MaxSystemNameLength} characters."); return; } @@ -91,24 +101,33 @@ public class SystemEdit var settings = await ctx.Repository.GetSystemGuild(ctx.Guild.Id, target.Id); - if (ctx.MatchRaw()) - { - if (settings.DisplayName != null) - await ctx.Reply($"```\n{settings.DisplayName}\n```"); - else + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) + if (settings.DisplayName == null) + { await ctx.Reply(noNameSetMessage); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"` ``\n{settings.DisplayName}\n` ``"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(settings.DisplayName); return; } if (!ctx.HasNext(false)) { - if (settings.DisplayName != null) - await ctx.Reply( - $"{(isOwnSystem ? "Your" : "This")} system's name for this server is currently **{settings.DisplayName}**." - + (isOwnSystem ? " Type `pk;system servername -clear` to clear it." : "") - + $" Using {settings.DisplayName.Length}/{Limits.MaxSystemNameLength} characters."); - else - await ctx.Reply(noNameSetMessage); + await ctx.Reply( + $"{(isOwnSystem ? "Your" : "This")} system's name for this server is currently **{settings.DisplayName}**." + + (isOwnSystem ? " Type `pk;system servername -clear` to clear it." : "") + + $" Using {settings.DisplayName.Length}/{Limits.MaxSystemNameLength} characters."); return; } @@ -143,28 +162,37 @@ public class SystemEdit if (isOwnSystem) noDescriptionSetMessage += " To set one, type `pk;s description `."; - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Description == null) + { await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"` ``\n{target.Description}\n` ``"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Description); return; } if (!ctx.HasNext(false)) { - if (target.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply(embed: new EmbedBuilder() - .Title("System description") - .Description(target.Description) - .Footer(new Embed.EmbedFooter( - "To print the description with formatting, type `pk;s description -raw`." - + (isOwnSystem ? " To clear it, type `pk;s description -clear`. To change it, type `pk;s description `." : "") - + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) - .Build()); + await ctx.Reply(embed: new EmbedBuilder() + .Title("System description") + .Description(target.Description) + .Footer(new Embed.EmbedFooter( + "To print the description with formatting, type `pk;s description -raw`." + + (isOwnSystem ? " To clear it, type `pk;s description -clear`. To change it, type `pk;s description `." : "") + + $" Using {target.Description.Length}/{Limits.MaxDescriptionLength} characters.")) + .Build()); return; } @@ -191,7 +219,7 @@ public class SystemEdit public async Task Color(Context ctx, PKSystem target) { var isOwnSystem = ctx.System?.Id == target.Id; - var matchedRaw = ctx.MatchRaw(); + var matchedFormat = ctx.MatchFormat(); var matchedClear = ctx.MatchClear(); if (!isOwnSystem || !(ctx.HasNext() || matchedClear)) @@ -199,8 +227,10 @@ public class SystemEdit if (target.Color == null) await ctx.Reply( "This system does not have a color set." + (isOwnSystem ? " To set one, type `pk;system color `." : "")); - else if (matchedRaw) + else if (matchedFormat == ReplyFormat.Raw) await ctx.Reply("```\n#" + target.Color + "\n```"); + else if (matchedFormat == ReplyFormat.Plaintext) + await ctx.Reply(target.Color); else await ctx.Reply(embed: new EmbedBuilder() .Title("System color") @@ -246,22 +276,31 @@ public class SystemEdit ? "You currently have no system tag set. To set one, type `pk;s tag `." : "This system currently has no system tag set."; - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Tag == null) + { await ctx.Reply(noTagSetMessage); - else - await ctx.Reply($"```\n{target.Tag}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.Tag}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Tag); return; } if (!ctx.HasNext(false)) { - if (target.Tag == null) - await ctx.Reply(noTagSetMessage); - else - await ctx.Reply($"{(isOwnSystem ? "Your" : "This system's")} current system tag is {target.Tag.AsCode()}." - + (isOwnSystem ? "To change it, type `pk;s tag `. To clear it, type `pk;s tag -clear`." : "")); + await ctx.Reply($"{(isOwnSystem ? "Your" : "This system's")} current system tag is {target.Tag.AsCode()}." + + (isOwnSystem ? "To change it, type `pk;s tag `. To clear it, type `pk;s tag -clear`." : "")); return; } @@ -296,15 +335,20 @@ public class SystemEdit var settings = await ctx.Repository.GetSystemGuild(ctx.Guild.Id, target.Id); - async Task Show(bool raw = false) + async Task Show(ReplyFormat format = ReplyFormat.Standard) { if (settings.Tag != null) { - if (raw) + if (format == ReplyFormat.Raw) { await ctx.Reply($"```{settings.Tag}```"); return; } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(settings.Tag); + return; + } var msg = $"Your current system tag in '{ctx.Guild.Name}' is {settings.Tag.AsCode()}"; if (!settings.TagEnabled) @@ -400,8 +444,8 @@ public class SystemEdit await EnableDisable(false); else if (ctx.Match("enable") || ctx.MatchFlag("enable")) await EnableDisable(true); - else if (ctx.MatchRaw()) - await Show(true); + else if (ctx.MatchFormat() != ReplyFormat.Standard) + await Show(ctx.MatchFormat()); else if (!ctx.HasNext(false)) await Show(); else @@ -418,24 +462,33 @@ public class SystemEdit if (isOwnSystem) noPronounsSetMessage += " To set some, type `pk;system pronouns `"; - if (ctx.MatchRaw()) - { + var format = ctx.MatchFormat(); + + // if there's nothing next or what's next is "raw"/"plaintext" we're doing a query, so check for null + if (!ctx.HasNext(false) || format != ReplyFormat.Standard) if (target.Pronouns == null) + { await ctx.Reply(noPronounsSetMessage); - else - await ctx.Reply($"```\n{target.Pronouns}\n```"); + return; + } + + if (format == ReplyFormat.Raw) + { + await ctx.Reply($"```\n{target.Pronouns}\n```"); + return; + } + if (format == ReplyFormat.Plaintext) + { + await ctx.Reply(target.Pronouns); return; } if (!ctx.HasNext(false)) { - if (target.Pronouns == null) - await ctx.Reply(noPronounsSetMessage); - else - await ctx.Reply($"{(isOwnSystem ? "Your" : "This system's")} current pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;system pronouns -raw`." - + (isOwnSystem ? " To clear them, type `pk;system pronouns -clear`." - : "") - + $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters."); + await ctx.Reply($"{(isOwnSystem ? "Your" : "This system's")} current pronouns are **{target.Pronouns}**.\nTo print the pronouns with formatting, type `pk;system pronouns -raw`." + + (isOwnSystem ? " To clear them, type `pk;system pronouns -clear`." + : "") + + $" Using {target.Pronouns.Length}/{Limits.MaxPronounsLength} characters."); return; }