Tidy up edit/deletion styles
parent
6a8ecfed8a
commit
adc54909fa
|
@ -119,15 +119,32 @@ const defaultFormatters = {
|
||||||
},
|
},
|
||||||
|
|
||||||
formatStaffReplyEditNotificationThreadMessage(threadMessage, newText, moderator) {
|
formatStaffReplyEditNotificationThreadMessage(threadMessage, newText, moderator) {
|
||||||
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) edited reply \`[${threadMessage.message_number}]\`:`;
|
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) edited reply \`${threadMessage.message_number}\``;
|
||||||
content += `\n\nBefore:\n\`\`\`${utils.disableCodeBlocks(threadMessage.body)}\`\`\``;
|
|
||||||
content += `\nAfter:\n\`\`\`${utils.disableCodeBlocks(newText)}\`\`\``;
|
if (threadMessage.body.length < 200 && newText.length < 200) {
|
||||||
|
// Show edits of small messages inline
|
||||||
|
content += ` from \`${utils.disableInlineCode(threadMessage.body)}\` to \`${newText}\``;
|
||||||
|
} else {
|
||||||
|
// Show edits of long messages in two code blocks
|
||||||
|
content += ":";
|
||||||
|
content += `\n\nBefore:\n\`\`\`${utils.disableCodeBlocks(threadMessage.body)}\`\`\``;
|
||||||
|
content += `\nAfter:\n\`\`\`${utils.disableCodeBlocks(newText)}\`\`\``;
|
||||||
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
},
|
},
|
||||||
|
|
||||||
formatStaffReplyDeletionNotificationThreadMessage(threadMessage, moderator) {
|
formatStaffReplyDeletionNotificationThreadMessage(threadMessage, moderator) {
|
||||||
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) deleted reply \`[${threadMessage.message_number}]\`:`;
|
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) deleted reply \`[${threadMessage.message_number}]\``;
|
||||||
content += "```" + utils.disableCodeBlocks(threadMessage.body) + "```";
|
|
||||||
|
if (threadMessage.body.length < 200) {
|
||||||
|
// Show the original content of deleted small messages inline
|
||||||
|
content += ` (message content: \`${utils.disableInlineCode(threadMessage.body)}\`)`;
|
||||||
|
} else {
|
||||||
|
// Show the original content of deleted large messages in a code block
|
||||||
|
content += ":\n```" + utils.disableCodeBlocks(threadMessage.body) + "```";
|
||||||
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,10 @@ function escapeMarkdown(str) {
|
||||||
return str.replace(markdownCharsRegex, "\\$1");
|
return str.replace(markdownCharsRegex, "\\$1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disableInlineCode(str) {
|
||||||
|
return str.replace(/`/g, "'");
|
||||||
|
}
|
||||||
|
|
||||||
function disableCodeBlocks(str) {
|
function disableCodeBlocks(str) {
|
||||||
return str.replace(/`/g, "`\u200b");
|
return str.replace(/`/g, "`\u200b");
|
||||||
}
|
}
|
||||||
|
@ -351,6 +355,7 @@ module.exports = {
|
||||||
humanizeDelay,
|
humanizeDelay,
|
||||||
|
|
||||||
escapeMarkdown,
|
escapeMarkdown,
|
||||||
|
disableInlineCode,
|
||||||
disableCodeBlocks,
|
disableCodeBlocks,
|
||||||
|
|
||||||
readMultilineConfigValue,
|
readMultilineConfigValue,
|
||||||
|
|
Loading…
Reference in New Issue