From 2d19142b44243a10fe5aa9766eb1c29b83a7bfd3 Mon Sep 17 00:00:00 2001 From: rladenson Date: Tue, 31 Dec 2024 05:15:21 -0700 Subject: [PATCH] feat: throw user-readable error for editing a message to be empty --- PluralKit.Bot/Commands/Message.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index 9a3b31fb..d9a93461 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -204,7 +204,7 @@ public class ProxiedMessage } // Append or prepend the new content to the original message content if needed. - // If no flag is supplied, the new contents will completly overwrite the old contents + // If no flag is supplied, the new contents will completely overwrite the old contents // If both flags are specified. the message will be prepended AND appended if (append && prepend) newContent = $"{newContent}{mutateSpace}{originalContent}{mutateSpace}{newContent}"; @@ -216,6 +216,12 @@ public class ProxiedMessage if (newContent.Length > 2000) throw new PKError("PluralKit cannot proxy messages over 2000 characters in length."); + // We count as an empty message even if there's an embed because the only embeds pk proxies are reply embeds and those aren't message content + if (newContent.Trim().Length == 0 && (originalMsg.Attachments.Length == 0 || clearAttachments)) + { + throw new PKError("This action would result in an empty message. If you wish to delete the message, react to it with \u274C."); + } + try { var editedMsg =