diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index bf376076..f396ae92 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -3,13 +3,12 @@ import { Attachment, Constants as ErisConstants, Guild, Member, Message, TextCha import humanizeDuration from "humanize-duration"; import { GuildCases } from "../data/GuildCases"; import { - chunkMessageLines, convertDelayStringToMS, createChunkedMessage, - disableLinkPreviews, errorMessage, findRelevantAuditLogEntry, formatTemplateString, + asSingleLine, stripObjectToScalars, successMessage, trimLines, @@ -483,23 +482,22 @@ export class ModActionsPlugin extends ZeppelinPlugin assume it's actually part of the reason @@ -594,19 +609,19 @@ export class ModActionsPlugin extends ZeppelinPlugin { const recentActions = this.getRecentActions(type, savedMessage.user_id, savedMessage.channel_id, since); // Start by muting them, if enabled + let timeUntilUnmute; if (spamConfig.mute && member) { const muteTime = spamConfig.mute_time ? spamConfig.mute_time * 60 * 1000 : 120 * 1000; + timeUntilUnmute = humanizeDuration(muteTime); this.logs.ignoreLog(LogType.MEMBER_ROLE_ADD, savedMessage.user_id); this.actions.fire("mute", { member, muteTime, reason: "Automatic spam detection" }); } @@ -288,10 +291,14 @@ export class SpamPlugin extends ZeppelinPlugin { // Create a case and log the actions taken above const caseType = spamConfig.mute ? CaseTypes.Mute : CaseTypes.Note; - const caseText = trimLines(` - Automatic spam detection: ${description} (over ${spamConfig.count} in ${spamConfig.interval}s) - ${archiveUrl} - `); + let caseText = trimLines(` + Automatic spam detection: ${description} (over ${spamConfig.count} in ${spamConfig.interval}s) + ${archiveUrl} + `); + + if (spamConfig.mute) { + caseText = `__[Muted for ${timeUntilUnmute}]__ ${caseText}`; + } this.logs.log(LogType.MESSAGE_SPAM_DETECTED, { member: stripObjectToScalars(member, ["user"]), diff --git a/src/utils.ts b/src/utils.ts index 796aedd3..11b83a7a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -199,6 +199,10 @@ export function trimLines(str: string) { .trim(); } +export function asSingleLine(str: string) { + return trimLines(str).replace(/\n/g, " "); +} + export const emptyEmbedValue = "\u200b"; export const embedPadding = "\n" + emptyEmbedValue;