0
votes

I made in my discord.js bot, command "nuke", which makes channel with same: name, permissions, topic etc, and delete "original" channel. But there is one problem, how to make channel in same position as "original"?

Here's my code:

const Discord = require('discord.js')

module.exports = {
    name: 'nuke',
    execute(message) {
        if (!message.member.hasPermission('ADMINISTRATOR')) {
            message.channel.send('missing permissions')
        }

        message.channel.clone().then(msg => msg.send('nuked'))
        message.channel.delete()
        
    },
};
3

3 Answers

2
votes

In the docs its stated that you can use setPosition to set the position

const Discord = require('discord.js')

module.exports = {
    name: 'nuke',
    execute(message) {
        if (!message.member.hasPermission('ADMINISTRATOR')) {
            message.channel.send('missing permissions')
        }

        message.channel.clone().then(channel => {
            channel.setPosition(message.channel.position)
            channel.send('nuked')
        })
        message.channel.delete()
        
    },
};
0
votes

Here is a simple piece of code that is not much. Its the nuke command crammed into a tiny piece of coding!

const { MessageEmbed } = require('discord.js')
module.exports = {
    name: "nuke",
    category: "",
    run: async (client, message, args) => {
        const link = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT9bZSle1XmET-H9Raq7HZA-7L5JH-zQnEeJKsCam2rcsZmjrLcs2nyTDds1hVNMqS11ck&usqp=CAU"
        message.channel.clone().then(channel => channel.send(link + ' ☢️ Channel nuked ☢️'));
        message.channel.delete();
    }
}
0
votes

You can also do

const Discord = require('discord.js')

module.exports.run = async (client, message, args) => {
  if (!message.member.hasPermission('MANAGE_CHANNELS')) {
    message.channel.send('You do not have the required Permissons to do that!')
  }

  message.channel.clone().then(channel => {
    channel.setPosition(message.channel.position)
    channel.send('https://i.gifer.com/6Ip.gif')
  })
  message.channel.delete()

},

  module.exports.help = {
    name: "nuke"
  }