feat(bot): add -nospace
(-ns
) flag to pk;edit
append/prepend mode
Also adds flag aliases `-a` (`-append`) and `-p` (prepend)
This commit is contained in:
parent
2fca75782c
commit
3db818741a
@ -103,8 +103,9 @@ public class ProxiedMessage
|
|||||||
throw new PKError("Could not edit message.");
|
throw new PKError("Could not edit message.");
|
||||||
|
|
||||||
// Check if we should append or prepend
|
// Check if we should append or prepend
|
||||||
var append = ctx.MatchFlag("append");
|
var mutateSpace = ctx.MatchFlag("nospace", "ns") ? "" : " ";
|
||||||
var prepend = ctx.MatchFlag("prepend");
|
var append = ctx.MatchFlag("append", "a");
|
||||||
|
var prepend = ctx.MatchFlag("prepend", "p");
|
||||||
|
|
||||||
// Grab the original message content and new message content
|
// Grab the original message content and new message content
|
||||||
var originalContent = originalMsg.Content;
|
var originalContent = originalMsg.Content;
|
||||||
@ -113,9 +114,9 @@ public class ProxiedMessage
|
|||||||
// Append or prepend the new content to the original message content if needed.
|
// 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 completly overwrite the old contents
|
||||||
// If both flags are specified. the message will be prepended AND appended
|
// If both flags are specified. the message will be prepended AND appended
|
||||||
if (append && prepend) newContent = $"{newContent} {originalContent} {newContent}";
|
if (append && prepend) newContent = $"{newContent}{mutateSpace}{originalContent}{mutateSpace}{newContent}";
|
||||||
else if (append) newContent = originalContent + " " + newContent;
|
else if (append) newContent = $"{originalContent}{mutateSpace}{newContent}";
|
||||||
else if (prepend) newContent = newContent + " " + originalContent;
|
else if (prepend) newContent = $"{newContent}{mutateSpace}{originalContent}";
|
||||||
|
|
||||||
if (newContent.Length > 2000)
|
if (newContent.Length > 2000)
|
||||||
throw new PKError("PluralKit cannot proxy messages over 2000 characters in length.");
|
throw new PKError("PluralKit cannot proxy messages over 2000 characters in length.");
|
||||||
|
Loading…
Reference in New Issue
Block a user