From 57f6c3db19525269b33a3b570122516d746e4c89 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 2 Apr 2021 14:12:47 -0500 Subject: [PATCH] Make sure botLogs channel exists before sending logs --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d4b4b0c..2423e7e 100644 --- a/index.js +++ b/index.js @@ -248,7 +248,9 @@ client.on('messageDelete', message => { console.error; } botLogsChannel = result.bot_logs_id; - message.guild.channels.cache.get(botLogsChannel).send(deleteEmbed).catch(console.error); + if (channel.guild.channels.cache.get(botLogsChannel)) { + channel.guild.channels.cache.get(botLogsChannel).send(deleteEmbed).catch(console.error); + } }); }); @@ -270,7 +272,9 @@ client.on('messageUpdate', (originalMessage, editedMessage) => { console.error; } botLogsChannel = result.bot_logs_id; - message.guild.channels.cache.get(botLogsChannel).send(editEmbed).catch(console.error); + if (channel.guild.channels.cache.get(botLogsChannel)) { + channel.guild.channels.cache.get(botLogsChannel).send(editEmbed).catch(console.error); + } }); } }); @@ -298,7 +302,9 @@ client.on('channelCreate', channel => { console.error; } botLogsChannel = result.bot_logs_id; - channel.guild.channels.cache.get(botLogsChannel).send(channelCreateEmbed).catch(console.error); + if (channel.guild.channels.cache.get(botLogsChannel)) { + channel.guild.channels.cache.get(botLogsChannel).send(channelCreateEmbed).catch(console.error); + } }); });