Tidy up edit/deletion styles

cshd
Dragory 2020-08-17 01:53:21 +03:00
parent 6a8ecfed8a
commit adc54909fa
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
2 changed files with 27 additions and 5 deletions

View File

@ -119,15 +119,32 @@ const defaultFormatters = {
},
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}\``;
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;
},
formatStaffReplyDeletionNotificationThreadMessage(threadMessage, moderator) {
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) deleted reply \`[${threadMessage.message_number}]\`:`;
content += "```" + utils.disableCodeBlocks(threadMessage.body) + "```";
let content = `**${moderator.user.username}#${moderator.user.discriminator}** (\`${moderator.id}\`) deleted reply \`[${threadMessage.message_number}]\``;
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;
},

View File

@ -306,6 +306,10 @@ function escapeMarkdown(str) {
return str.replace(markdownCharsRegex, "\\$1");
}
function disableInlineCode(str) {
return str.replace(/`/g, "'");
}
function disableCodeBlocks(str) {
return str.replace(/`/g, "`\u200b");
}
@ -351,6 +355,7 @@ module.exports = {
humanizeDelay,
escapeMarkdown,
disableInlineCode,
disableCodeBlocks,
readMultilineConfigValue,