Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

294
Visualizações
Make a cloned channel in same position as the original

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

Here's my code:

module.exports = {
  name: 'nuke',
  aliases: [ 'clearall' ],
  guildOnly: true,
  permissions: [ 'MANAGE_MESSAGES', 'MANAGE_CHANNELS' ],
  clientPermissions: [ 'MANAGE_CHANNELS' ],
  group: 'moderation',
  description: 'Removes all messages in the channel (Deletes the old channel and makes a copy of it with permissions intact)',
  examples: [
    'nuke',
    'clearall'
  ],
  run: async (client, message) => {

    await message.channel.send(`This will remove all conversation in this channel and may cause conflict for bots using ID to track channels. Continue?`);

    const filter = _message => message.author.id === _message.author.id && ['y','n','yes','no'].includes(_message.content.toLowerCase());
    const options = { max: 1, time: 30000, errors: ['time'] };
    const proceed = await message.channel.awaitMessages(filter, options)
    .then(collected => ['y','yes'].includes(collected.first().content.toLowerCase()) ? true : false)
    .catch(() => false);

    if (!proceed){
      return message.channel.send(`\\❌ | **${message.author.tag}**, you cancelled the nuke command!`);
    };

    return message.channel.send(`The nuke has been deployed, saying goodbye to **#${message.channel.name}** in 10`)
    .then(() => setTimeout(() => message.channel.clone()
    .then(() => message.channel.delete().catch(() => null)), 10000))
  }
};
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Channels have a position property so you could set the cloned channel's position to this number using the .setPosition() method. You can get the cloned channel after the .clone() method is resolved:

return message.channel
  .send(
    `The nuke has been deployed, saying goodbye to **#${message.channel.name}** in 10`,
  )
  .then(() =>
    setTimeout(
      () =>
        message.channel.clone().then((clonedChannel) => {
          const originalPosition = message.channel.position;

          message.channel.delete().catch(() => null);
          clonedChannel.setPosition(originalPosition);
        }),
      10000,
    ),
  );
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda