Fix logMessage variable not working in automod alert

This commit is contained in:
Dragory 2021-08-20 20:31:36 +03:00
parent bd2c51691a
commit 0b28215208
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -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,