From 89d674567ea05230ad4b72409729f519e9fd9092 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sat, 3 Apr 2021 12:14:04 -0500 Subject: [PATCH] Attempt to add kulboardCreate() function --- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/index.js b/index.js index 5159ea8..1899f39 100644 --- a/index.js +++ b/index.js @@ -56,6 +56,9 @@ client.on("message", async message => { case `${prefix}startlogs`: startLogs(message); break; + case `${prefix}kulboard`: + kulboardCreate(message) + break; } if (message.content.toLowerCase().startsWith(`${prefix}bulkdelete`)) { @@ -107,6 +110,52 @@ async function startLogs(message) { }); } +async function kulboardCreate(message) { + if (!message.member.hasPermission("ADMINISTRATOR")) { + message.reply("you do not have admin permissions!"); + return; + } + collection.findOne({ guild_id: message.guild.id }, (error, result) => { + if (error) { + console.error; + } + if (result.kulboard_id) { + kulboardChannel = result.kulboard_id; + if (message.guild.channels.cache.get(kulboardChannel)) { + message.reply('bot logs channel already exists!'); + } else { + // Create "#bot-logs" text channel to track message deletes, edits, and channel creations + message.guild.channels.create('külboard', { + 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: { "kulboard_id": `${channel.id}` } }); + }).catch(message.reply(`unable to create channel :(`)); + } + } else { + // Create "#bot-logs" text channel to track message deletes, edits, and channel creations + message.guild.channels.create('külboard', { + 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: { "kulboard_id": `${channel.id}` } }); + }).catch(message.reply(`unable to create channel :(`)); + } + }); +} + async function userInfo(message) { if (!message.content.split(" ")[1]) { message.reply("query must contain at least 3 characters!")