From 655cc99ecb7cb9d793f5092c5c1b373f8bdb4ef0 Mon Sep 17 00:00:00 2001 From: Dragory Date: Sat, 12 Jan 2019 12:20:05 +0200 Subject: [PATCH] ModActions: show longer notes in !cases, add indicator for extra notes --- src/plugins/ModActions.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index dde2a1b5..b8d6ef42 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -5,6 +5,7 @@ import { GuildCases } from "../data/GuildCases"; import { chunkMessageLines, convertDelayStringToMS, + createChunkedMessage, disableLinkPreviews, errorMessage, findRelevantAuditLogEntry, @@ -34,10 +35,10 @@ interface IIgnoredEvent { userId: string; } -const CASE_LIST_REASON_MAX_LENGTH = 80; +const CASE_LIST_REASON_MAX_LENGTH = 300; export class ModActionsPlugin extends ZeppelinPlugin { - public static pluginName = 'mod_actions'; + public static pluginName = "mod_actions"; protected actions: GuildActions; protected mutes: GuildMutes; @@ -893,7 +894,7 @@ export class ModActionsPlugin extends ZeppelinPlugin { const prefix = this.knub.getGuildData(this.guildId).config.prefix; if (cases.length === 0) { - msg.channel.createMessage(`No cases found for ${user ? `**${userName}**` : 'the specified user'}`); + msg.channel.createMessage(`No cases found for ${user ? `**${userName}**` : "the specified user"}`); } else { if (args.expanded && args.expanded.startsWith("expand")) { if (cases.length > 8) { @@ -917,7 +918,7 @@ export class ModActionsPlugin extends ZeppelinPlugin { let reason = firstNote ? firstNote.body : ""; if (reason.length > CASE_LIST_REASON_MAX_LENGTH) { - const match = reason.slice(CASE_LIST_REASON_MAX_LENGTH, 20).match(/(?:[.,!?\s]|$)/); + const match = reason.slice(CASE_LIST_REASON_MAX_LENGTH, 100).match(/(?:[.,!?\s]|$)/); const nextWhitespaceIndex = match ? CASE_LIST_REASON_MAX_LENGTH + match.index : CASE_LIST_REASON_MAX_LENGTH; if (nextWhitespaceIndex < reason.length) { reason = reason.slice(0, nextWhitespaceIndex - 1) + "..."; @@ -926,7 +927,10 @@ export class ModActionsPlugin extends ZeppelinPlugin { reason = disableLinkPreviews(reason); - lines.push(`Case \`#${theCase.case_number}\` __${CaseTypes[theCase.type]}__ ${reason}`); + let line = `Case \`#${theCase.case_number}\` __${CaseTypes[theCase.type]}__ ${reason}`; + if (theCase.notes.length > 1) line += ` (+ ${theCase.notes.length - 1} notes)`; + + lines.push(line); } const finalMessage = trimLines(` @@ -937,10 +941,7 @@ export class ModActionsPlugin extends ZeppelinPlugin { Use \`${prefix}case \` to see more info about individual cases `); - const finalMessageChunks = chunkMessageLines(finalMessage); - for (const msgChunk of finalMessageChunks) { - msg.channel.createMessage(msgChunk); - } + createChunkedMessage(msg.channel, finalMessage); } } }