Fix error with unknown mod_actions alert_channel

This commit is contained in:
Dragory 2020-08-21 03:51:03 +03:00
parent 1787ec707c
commit 6730e51552
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -1,5 +1,7 @@
import { eventListener } from "knub";
import { ModActionsPluginType } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
/**
* Show an alert if a member with prior notes joins the server
@ -18,6 +20,13 @@ export const PostAlertOnMemberJoinEvt = eventListener<ModActionsPluginType>()(
if (actions.length) {
const alertChannel: any = pluginData.guild.channels.get(alertChannelId);
if (!alertChannel) {
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,
});
return;
}
alertChannel.send(
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
);