From b997742223e6ff27b7f76ee88affc1327a13174e Mon Sep 17 00:00:00 2001 From: naseif Date: Wed, 3 Nov 2021 09:58:41 +0000 Subject: [PATCH] [New] Added nuke command --- commands/Admin/nuke.js | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 commands/Admin/nuke.js diff --git a/commands/Admin/nuke.js b/commands/Admin/nuke.js new file mode 100644 index 0000000..82090eb --- /dev/null +++ b/commands/Admin/nuke.js @@ -0,0 +1,77 @@ +const { SlashCommandBuilder } = require("@discordjs/builders"); +const { embedMessage } = require("../../modules/embedSimple"); + +module.exports = { + name: "nuke", + args: true, + usage: "nuke || nuke ", + description: "Deletes a text channel and recreates it with same permissions", + async run(message, args, client) { + if (!message.member.permissions.has("ADMINISTRATOR")) + return await message.channel.send({ + embeds: [ + embedMessage( + "#9dcc37", + `❌ You do not have permission to nuke this channel.\nOnly Server Admins have the permission to perform this action` + ), + ], + }); + + if (!args[0]) { + try { + const cloneChannel = await message.channel.clone(); + const deleteChannel = await message.channel.delete(); + await cloneChannel.setPosition(deleteChannel.rawPosition); + const newChannel = message.guild.channels.cache.find( + (channel) => channel.name === cloneChannel.name + ); + return await newChannel.send({ + content: "✅ | Channel has been nuked :D", + files: ["https://c.tenor.com/Naz32m5Pp6YAAAAC/nuke.gif"], + }); + } catch (err) { + client.logger(err.message, "error"); + return await message.channel.send({ + embeds: [ + embedMessage( + "#9dcc37", + `❌ | Could not nuke the Channel!\nError: ${err.message}` + ), + ], + }); + } + } + + try { + const channel = message.guild.channels.cache.find( + (channel) => channel.id === args[0] + ); + const channelClone = await channel.clone(); + const nukeChannel = await channel.delete(); + await channelClone.setPosition(nukeChannel.rawPosition); + const newCreatedChannel = message.guild.channels.cache.find( + (channel) => channel.name === channelClone.name + ); + return await newCreatedChannel.send({ + content: "✅ | Channel has been nuked :D", + files: ["https://c.tenor.com/Naz32m5Pp6YAAAAC/nuke.gif"], + }); + } catch (err) { + client.logger(err.message, "error"); + return await message.channel.send({ + embeds: [ + embedMessage( + "#9dcc37", + `❌ | Could not nuke the Channel!\nError: ${err.message}` + ), + ], + }); + } + }, + data: new SlashCommandBuilder() + .setName("nuke") + .setDescription( + "Deletes a text channel and recreates it with same permissions" + ), + async execute(interaction, client) {}, +};