Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

740
Vistas
Discord.JS - Moving users in Discord to your VC using roles

I'm trying to move all users from a VC with a specific role, for example: !summon @role

With that, all users with that specific role should come to the VC where the user typed that command

At the moment my code looks like this:

else if (command === 'summon') {
                    const channel = message.member.voice.channel;
                    message.guild.members.cache.forEach(member => {
                        member.voice.setChannel(channel);
                    });
                    message.channel.send(`${message.author} users moved to your channel!`);
                }

At the moment i'm moving all users, however I only want users with the informed role

I tried to use:

                    message.mentions.roles.forEach(member => {
                        member.setChannel(channel);
                    });

But without success... can someone help me with this problem?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can try replacing

message.guild.members.cache.forEach(member => {
    member.voice.setChannel(channel);
});

with

message.guild.members.cache.forEach(member => {
    if(member.roles.cache.has(message.mentions.roles.first()) {
        member.voice.setChannel(channel);
    }
}

Since member.roles.cache is a Collection it has a function .has. We take the first role mention from the message using message.mentions.roles.first() and check if it exists in the user's current roles using member.roles.cache.has(). If the user does have the first role mentioned in the message, the function returns true and we can move the to the specified channel. Hope this helps, don't forget about https://discord.js.org/#/docs for some documentation, can be quite useful 😅.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda