From 23fe9044645df5a6bc4ccf29344b18a1b5356831 Mon Sep 17 00:00:00 2001 From: Petal Ladenson Date: Thu, 3 Oct 2024 02:23:33 -0600 Subject: [PATCH] feat(bot): add -plaintext flag alongside -raw --- .../Context/ContextArgumentsExt.cs | 15 +- PluralKit.Bot/Commands/Groups.cs | 104 ++++++---- PluralKit.Bot/Commands/MemberEdit.cs | 132 ++++++++---- PluralKit.Bot/Commands/Message.cs | 39 ++-- PluralKit.Bot/Commands/SystemEdit.cs | 194 ++++++++++++------ 5 files changed, 322 insertions(+), 162 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs index 9a93440b..1a958c8e 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs @@ -91,8 +91,12 @@ 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 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) { @@ -184,4 +188,11 @@ public static class ContextArgumentsExt return groups; } +} + +public enum ReplyFormat +{ + Standard, + Raw, + Plaintext } \ No newline at end of file diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index 7e4bc955..36726056 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -132,40 +132,47 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing displayname for group {target.Reference(ctx)}"); + await ctx.Reply(target.DisplayName, embed: eb.Build()); 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 +208,41 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing description for group {target.Reference(ctx)}"); + await ctx.Reply(target.Description, embed: eb.Build()); 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 +403,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 +411,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..3c19c171 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -70,30 +70,41 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing description for member {target.Reference(ctx)}"); + await ctx.Reply(target.Description, embed: eb.Build()); 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 +137,37 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing pronouns for member {target.Reference(ctx)}"); + await ctx.Reply(target.Pronouns, embed: eb.Build()); 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 +254,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 +262,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 +412,26 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing displayname for member {target.Reference(ctx)}"); + await ctx.Reply(target.DisplayName, embed: eb.Build()); return; } @@ -450,12 +488,26 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing servername for member {target.Reference(ctx)}"); + await ctx.Reply(memberGuildConfig.DisplayName, embed: eb.Build()); return; } diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index b45639d7..ca423f94 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 != ReplyFormat.Standard) { var discordMessage = await _rest.GetMessageOrNull(message.Message.Channel, message.Message.Mid); if (discordMessage == null || !showContent) @@ -365,21 +367,32 @@ public class ProxiedMessage return; } - await ctx.Reply($"```{content}```"); - - if (Regex.IsMatch(content, "```.*```", RegexOptions.Singleline)) + if (format == 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 == ReplyFormat.Plaintext) + { + var eb = new EmbedBuilder() + .Description($"Showing contents of message {message.Message.Mid}"); + await ctx.Reply(content, embed: eb.Build()); + return; } - return; } if (isDelete) diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index a3bcaa64..2ff0c528 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -37,24 +37,35 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing name for system {target.DisplayHid()}"); + await ctx.Reply(target.Name, embed: eb.Build()); 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 +102,35 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing servername for system {target.DisplayHid()}"); + await ctx.Reply(settings.DisplayName, embed: eb.Build()); 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 +165,39 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing description for system {target.DisplayHid()}"); + await ctx.Reply(target.Description, embed: eb.Build()); 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 +224,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 +232,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 +281,33 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing tag for system {target.DisplayHid()}"); + await ctx.Reply(target.Tag, embed: eb.Build()); 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 +342,22 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing servertag for system {target.DisplayHid()}"); + await ctx.Reply(settings.Tag, embed: eb.Build()); + return; + } var msg = $"Your current system tag in '{ctx.Guild.Name}' is {settings.Tag.AsCode()}"; if (!settings.TagEnabled) @@ -400,8 +453,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 +471,35 @@ 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) + { + var eb = new EmbedBuilder() + .Description($"Showing pronouns for system {target.DisplayHid()}"); + await ctx.Reply(target.Pronouns, embed: eb.Build()); 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; }