107 lines
3.3 KiB
JavaScript
107 lines
3.3 KiB
JavaScript
const Discord = require("discord.js")
|
|
const db = require("../../database");
|
|
let cooldown = new Set();
|
|
const config = require("../../config")
|
|
|
|
module.exports = {
|
|
name: "auto-setup",
|
|
aliases: ['autosetup'],
|
|
description: "autosetup the bot",
|
|
category: "alt-detector",
|
|
run: async (client, message, member) => {
|
|
|
|
|
|
if (!message.member.hasPermission("MANAGE_GUILD")) {
|
|
await message.delete()
|
|
return message.channel.send(`**Sie haben keine Berechtigung, diesen Befehl zu verwenden**`)
|
|
}
|
|
|
|
if(cooldown.has(message.author.id)) {
|
|
message = await
|
|
message.channel.send({embed: {color: "#10de47", description: `**You need to wait __${config.COOLDOWN}__ Minuten, um diesen Befehl erneut zu verwenden!**`}});
|
|
setTimeout(() => {
|
|
message.delete();
|
|
}, 3000);
|
|
} else {
|
|
|
|
let embed = new Discord.MessageEmbed()
|
|
.setColor('RANDOM')
|
|
.setTitle("AUTO SETUP")
|
|
.setTimestamp()
|
|
.setFooter("Bot von M_Viper#8085");
|
|
|
|
let xd = await message.channel.send(embed)
|
|
xd.react("✅")
|
|
xd.react("❌")
|
|
|
|
const filter = (reaction, user) => {
|
|
return ['✅', '❌'].includes(reaction.emoji.name) && user.id === message.author.id;
|
|
};
|
|
|
|
xd.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
|
|
.then(async collected => {
|
|
const reaction = collected.first();
|
|
|
|
if (reaction.emoji.name === '✅') {
|
|
let channel = client.channels.cache.find(x => x.name === "alt-logging")
|
|
if (channel) {
|
|
channel.delete().catch(console.log)
|
|
}
|
|
await message.guild.channels.create('alt-logging', {
|
|
type: 'text',
|
|
permissionsOverwrites: [{
|
|
id: message.guild.id,
|
|
deny: ['SEND_MESSAGES'],
|
|
allow: ['VIEW_CHANNEL']
|
|
}]
|
|
})
|
|
let role = message.guild.roles.cache.find(role => role.name === "alt-notify")
|
|
if (role) {
|
|
role.delete().catch(console.log)
|
|
}
|
|
await message.guild.roles.create({
|
|
data: {
|
|
name: 'alt-notify',
|
|
color: 'RANDOM',
|
|
}
|
|
})
|
|
|
|
let LoggingChannel = client.channels.cache.find(x => x.name === "alt-logging")
|
|
await db.delete(`LoggingChannel_${message.guild.id}`)
|
|
await db.set(`LoggingChannel_${message.guild.id}`, LoggingChannel.id)
|
|
|
|
let notifyRole = message.guild.roles.cache.find(role => role.name === "alt-notify")
|
|
await db.delete(`notifyRole_${message.guild.id}`)
|
|
await db.set(`notifyRole_${message.guild.id}`, notifyRole)
|
|
|
|
let AutoSetupEmbed = new Discord.MessageEmbed()
|
|
.setColor("RANDOM")
|
|
.setDescription(`**__Automatisches Setup wird ausgeführt__** \n **Bitte warten Sie eine Weile ....**`)
|
|
.setFooter("Bot von M_Viper#8085");
|
|
|
|
let AutoSetupDoneEmbed = new Discord.MessageEmbed()
|
|
.setColor("RANDOM")
|
|
.setDescription(`**__AUTO SETUP FERTIG__** \n **Nun ist Alt Logging Channel ${LoggingChannel} \n Und Alt Notify Role ist ${notifyRole}**`)
|
|
.setFooter("Bot von M_Viper#8085");
|
|
|
|
message = await
|
|
message.channel.send(AutoSetupEmbed)
|
|
setTimeout(() => {
|
|
message.edit(AutoSetupDoneEmbed);
|
|
}, 1000);
|
|
} else {
|
|
message.reply('In Ordnung ! Vorgang wurde abgebrochen');
|
|
}
|
|
})
|
|
.catch(collected => {
|
|
if(xd.reactions.cache.size !== null) return
|
|
else message.reply(`Zeit vorbei ! Du hast nicht reagiert`);
|
|
})
|
|
}
|
|
cooldown.add(message.author.id);
|
|
setTimeout(() => {
|
|
cooldown.delete(message.author.id);
|
|
}, config.COOLDOWN * 60 * 1000);
|
|
}
|
|
|
|
} |