From c67193c3983df03f3340ca4f3da4a0db4c998432 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 1 Jun 2025 22:35:39 +0000 Subject: [PATCH] fix: unescaped echo of matched word in match_words log --- backend/src/plugins/Automod/triggers/matchWords.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Automod/triggers/matchWords.ts b/backend/src/plugins/Automod/triggers/matchWords.ts index 764eb87c..0c324e53 100644 --- a/backend/src/plugins/Automod/triggers/matchWords.ts +++ b/backend/src/plugins/Automod/triggers/matchWords.ts @@ -5,6 +5,7 @@ import { stripMarkdown } from "../../../utils/stripMarkdown.js"; import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary.js"; import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage.js"; import { automodTrigger } from "../helpers.js"; +import { escapeInlineCode } from "discord.js"; interface MatchResultType { word: string; @@ -83,7 +84,8 @@ export const MatchWordsTrigger = automodTrigger()({ for (const regex of regexes) { const match = regex.exec(str); if (match) { - const matchedWord = match.slice(1).find(group => group !== undefined) || ""; + const matchedWordIndex = match.slice(1).findIndex(group => group !== undefined); + const matchedWord = trigger.words[matchedWordIndex]; return { extra: { @@ -100,7 +102,7 @@ export const MatchWordsTrigger = automodTrigger()({ renderMatchInformation({ pluginData, contexts, matchResult }) { const partialSummary = getTextMatchPartialSummary(pluginData, matchResult.extra.type, contexts[0]); - const wordInfo = matchResult.extra.word ? ` (matched: "${matchResult.extra.word}")` : ""; - return `Matched word in ${partialSummary}${wordInfo}`; + const wordInfo = matchResult.extra.word ? ` (\`${escapeInlineCode(matchResult.extra.word)}\`)` : ""; + return `Matched word${wordInfo} in ${partialSummary}`; }, -}); \ No newline at end of file +});