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

167
Visualizações
DiscordJS move all members in a specific vc

I'm trying to find a way to move all members which are in a specific vc to the vc which the sender of the command is in. The command should be -warp. This is what i have so far:

        if (!message.member?.permissions.has('MOVE_MEMBERS')) return;
        const member = message.mentions.members?.first();
        if (!member) return message.reply("Error: Didn't specify member.");
        if (!member.voice.channel) return message.reply("Error: Mentioned member is not in a Voice Channel.");

        if (!message.member.voice.channel) return message.reply("Error: Executor of command is not in a Voice Channel.");
        member.voice.setChannel(message.member.voice.channel)
        message.reply('Success: Moved member.')

It works but i can only move one user at the time and from every vc. I want everyone to be able to move others but only from a specific vc. Thanks for your help!

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

This works for me, let me know if you have any troubles:

client.on('messageCreate', async message => {
    if (message.author.bot) return;
    if (message.content === '-warp') {
        // doing the same validation here as you did
        if (!message.member.voice.channel) {
            await message.reply('Error: Executor of command is not in a Voice Channel.');
            return;
        }
        const sendersChannel = message.member.voice.channel;
        const mentionedMember = message.mentions.members?.first();
        if (!mentionedMember) {
            await message.reply('Error: Didn\'t specify member.');
            return;
        }
        if (!mentionedMember.voice.channel) {
            await message.reply('Error: Mentioned member is not in a Voice Channel.');
            return;
        }
        // get the channel of the mentioned member
        const targetChannel = mentionedMember.voice.channel;
        // iterate over all the members in that voice channel and move them to the sender's channel
        for (const [, member] of targetChannel.members) {
            await member.voice.setChannel(sendersChannel);
        }
        await message.reply(`Moved all members from ${targetChannel.name} to ${sendersChannel.name}`);
    }
});
about 4 years ago · Juan Pablo Isaza Relatório

0

Give this a try

    const channel2pullFrom = message.guild.channels.cache.get(‘channelID’)
    const sendersChannel = message.member.voice.channel.id

    if (!message.member.permissions.has('MOVE_MEMBERS')) return
    if (!message.member.voice.channel) return message.reply("Error: Executor of command is not in a Voice Channel.")
   
    channel2pullFrom.members.map((member) => {
        member.voice.setChannel(sendersChannel)
    })
   
    message.reply(`Moved members.`)

Code:

https://i.stack.imgur.com/JLrmP.png

Before Command:

https://i.stack.imgur.com/VGbyp.png

After Command:

https://i.stack.imgur.com/tTUF4.png

about 4 years ago · Juan Pablo Isaza Relatório

0

Use the forEach function.

members.forEach(member => {
//member…
}
about 4 years ago · Juan Pablo Isaza 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