From 0b28215208eb3b50addd3ee7ea9a90ce24035afb Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Fri, 20 Aug 2021 20:31:36 +0300 Subject: [PATCH] Fix logMessage variable not working in automod alert --- backend/src/plugins/Automod/actions/alert.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/actions/alert.ts b/backend/src/plugins/Automod/actions/alert.ts index 6c63e5ce..314bb552 100644 --- a/backend/src/plugins/Automod/actions/alert.ts +++ b/backend/src/plugins/Automod/actions/alert.ts @@ -16,10 +16,12 @@ import { tNormalizedNullOptional, isTruthy, verboseChannelMention, + validateAndParseMessageContent, } from "../../../utils"; import { LogsPlugin } from "../../Logs/LogsPlugin"; import { automodAction } from "../helpers"; import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; +import { messageIsEmpty } from "../../../utils/messageIsEmpty"; export const AlertAction = automodAction({ configType: t.type({ @@ -66,7 +68,7 @@ export const AlertAction = automodAction({ actionsTaken, matchSummary: matchResult.summary, messageLink: theMessageLink, - logMessage: logMessage?.content, + logMessage: validateAndParseMessageContent(logMessage)?.content, }), ); } catch (err) { @@ -80,6 +82,13 @@ export const AlertAction = automodAction({ throw err; } + if (messageIsEmpty(rendered)) { + pluginData.getPlugin(LogsPlugin).logBotAlert({ + body: `Tried to send alert with an empty message for automod rule ${ruleName}`, + }); + return; + } + try { await createChunkedMessage( channel,