3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

Handle errors when sending message in automod 'alert' action

This commit is contained in:
Dragory 2021-04-04 22:30:21 +03:00
parent fdaf386193
commit 186ac65924
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -9,6 +9,7 @@ import {
resolveMember, resolveMember,
stripObjectToScalars, stripObjectToScalars,
tNullable, tNullable,
verboseChannelMention,
} from "../../../utils"; } from "../../../utils";
import { resolveActionContactMethods } from "../functions/resolveActionContactMethods"; import { resolveActionContactMethods } from "../functions/resolveActionContactMethods";
import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin"; import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
@ -68,7 +69,23 @@ export const AlertAction = automodAction({
throw err; throw err;
} }
await createChunkedMessage(channel, rendered); try {
await createChunkedMessage(channel, rendered);
} catch (err) {
if (err.code === 50001) {
logs.log(LogType.BOT_ALERT, {
body: `Missing access to send alert to channel ${verboseChannelMention(
channel,
)} in automod rule **${ruleName}**`,
});
} else {
logs.log(LogType.BOT_ALERT, {
body: `Error ${err.code || "UNKNOWN"} when sending alert to channel ${verboseChannelMention(
channel,
)} in automod rule **${ruleName}**`,
});
}
}
} else { } else {
logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
body: `Invalid channel id \`${actionConfig.channel}\` for alert action in automod rule **${ruleName}**`, body: `Invalid channel id \`${actionConfig.channel}\` for alert action in automod rule **${ruleName}**`,