Browse Source

Attempt to add kulboardCreate() function

master
Abheek Dhawan 4 years ago
parent
commit
89d674567e
  1. 49
      index.js

49
index.js

@ -56,6 +56,9 @@ client.on("message", async message => {
case `${prefix}startlogs`: case `${prefix}startlogs`:
startLogs(message); startLogs(message);
break; break;
case `${prefix}kulboard`:
kulboardCreate(message)
break;
} }
if (message.content.toLowerCase().startsWith(`${prefix}bulkdelete`)) { 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) { async function userInfo(message) {
if (!message.content.split(" ")[1]) { if (!message.content.split(" ")[1]) {
message.reply("query must contain at least 3 characters!") message.reply("query must contain at least 3 characters!")

Loading…
Cancel
Save