From ad4b019eea2e32dd8965eaf14454b5bdfaebebf5 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sat, 3 Apr 2021 12:21:07 -0500 Subject: [PATCH] Make sure bot logs channel gets created even if it's not found in database --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 77e58e7..1ccb8cc 100644 --- a/index.js +++ b/index.js @@ -104,8 +104,22 @@ async function startLogs(message) { // Add the ID of the "#bot-logs" channel to the database message.reply(`channel ${channel} created!`) collection.updateOne({ guild_id: message.guild.id }, { $set: { "bot_logs_id": `${channel.id}` } }); - }).catch(message.reply(`unable to create channel :(`)); + }).catch(console.error); } + } else { + // Create "#bot-logs" text channel to track message deletes, edits, and channel creations + message.guild.channels.create('bot-logs', { + type: 'text', + // Remove view permissions from "@everyone" + permissionOverwrites: [{ + id: message.guild.id, + deny: ['VIEW_CHANNEL'], + }] + }).then(channel => { + // Add the ID of the "#bot-logs" channel to the database + message.reply(`channel ${channel} created!`) + collection.updateOne({ guild_id: message.guild.id }, { $set: { "bot_logs_id": `${channel.id}` } }); + }).catch(console.error); } }); }