0
votes

i have written a code for my nuke commad which is

const { MessageEmbed } = require('discord.js')
module.exports = {
    name: "nuke",
    description: "Nukes a given channel",
    run: async(client, message, args) => {
        if(!message.member.hasPermission("ADMINISTRATOR")) {
            return message.reply("You do not have the perms to use this cmd!")
        }
        let reason = args.join(" ") || "No Reason"
        if(!message.channel.deletable) {
            return message.reply("This channel cannot be nuked!")
        }
        let newchannel = await message.channel.clone()
        await message.channel.delete()
        let embed = new MessageEmbed()
        .setTitle("Channel Nuked")
        .setDescription(reason)
        .setImage('https://media0.giphy.com/media/oe33xf3B50fsc/200.gif')
        await newchannel.send(embed)
    }
}

but i want it so clone the channel and set the position of it the same as the channel which has been nuked but it isnt happening

1
this command dosent put the channel into its correct spot please helpits blue

1 Answers

0
votes

Then before clone() you grab parent and position and reset it after delete()

const oldParent = message.channel.parent;
const oldPosition = message.channel.position;
const newchannel = await message.channel.clone() 
await message.channel.delete()
if (!!oldPosition) {
    newchannel.setPosition(oldPosition, true);
}
if (!!oldParent) {
    newchannel.setParent(oldParent); 
}