From 6730e515527f9cf0d30c5891f8965b4e83df3ae7 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Fri, 21 Aug 2020 03:51:03 +0300 Subject: [PATCH] Fix error with unknown mod_actions alert_channel --- .../ModActions/events/PostAlertOnMemberJoinEvt.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/src/plugins/ModActions/events/PostAlertOnMemberJoinEvt.ts b/backend/src/plugins/ModActions/events/PostAlertOnMemberJoinEvt.ts index 92e50bd5..80b71bb2 100644 --- a/backend/src/plugins/ModActions/events/PostAlertOnMemberJoinEvt.ts +++ b/backend/src/plugins/ModActions/events/PostAlertOnMemberJoinEvt.ts @@ -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()( 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)`, );