diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index 199d452e..5f91479a 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -51,15 +51,28 @@ public class ProxiedMessage if (!ctx.HasNext()) throw new PKSyntaxError("You need to include the message to edit in."); - var newContent = ctx.RemainderOrNull().NormalizeLineEndSpacing(); - - if (newContent.Length > 2000) - throw new PKError("PluralKit cannot proxy messages over 2000 characters in length."); - var originalMsg = await _rest.GetMessageOrNull(msg.Message.Channel, msg.Message.Mid); if (originalMsg == null) throw new PKError("Could not edit message."); + // Check if we should append or prepend + var append = ctx.MatchFlag("append"); + var prepend = ctx.MatchFlag("prepend"); + + // Grab the original message content and new message content + var originalContent = originalMsg.Content; + var newContent = ctx.RemainderOrNull().NormalizeLineEndSpacing(); + + // 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 both flags are specified. the message will be prepended AND appended + if (append && prepend) newContent = $"{newContent} {originalContent} {newContent}"; + else if (append) newContent = originalContent +" "+ newContent; + else if (prepend) newContent = newContent +" "+ originalContent; + + if (newContent.Length > 2000) + throw new PKError("PluralKit cannot proxy messages over 2000 characters in length."); + try { var editedMsg = diff --git a/docs/content/tips-and-tricks.md b/docs/content/tips-and-tricks.md index 3fb59bc7..c67a2fe6 100644 --- a/docs/content/tips-and-tricks.md +++ b/docs/content/tips-and-tricks.md @@ -74,6 +74,8 @@ You cannot look up private members or groups of another system. |pk;system frontpercent|-flat||Show "flat" frontpercent - percentages add up to 100%| |pk;group \ frontpercent|-fronters-only|-fo|Show a group's frontpercent without the "no fronter" entry| |pk;group \ frontpercent|-flat||Show "flat" frontpercent - percentages add up to 100%| +|pk;edit|-append||Append the new content to the old message instead of overwriting it| +|pk;edit|-prepend||Prepend the new content to the old message instead of overwriting it| |Most commands|-all|-a|Show hidden/private information| |Most commands|-raw|-r|Show text with formatting, for easier copy-pasting| |All commands|-private|-priv|Show private information|