mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Handle errors when sending message in automod 'alert' action
This commit is contained in:
parent
fdaf386193
commit
186ac65924
1 changed files with 18 additions and 1 deletions
|
@ -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}**`,
|
||||||
|
|
Loading…
Add table
Reference in a new issue