0

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 Answers 3

3

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()
        
    },
};
Sign up to request clarification or add additional context in comments.

Comments

0

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();
    }
}

Comments

0

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"
  }

2 Comments

Please provide some explanation. See How do I write a good answer?
This solution is very low quality and provides no new information from the accepted answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.