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

106
Vistas
How do I get all members with a role?

I'm trying to send a DM to all members with a specific role. I've tried that to get members with a role:

guild.roles.cache.get(ROLE_ID).members

and

guild.roles.fetch(ROLE_ID)

My problem is that the bot only returns my user.

I know someone has asked a question like this before where it was solved using the correct intents, but it's not the case for me.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think the problem is that Role#members returns a Collection of the cached guild members only that have this role. Try to fetch all members first and then try again:

let members = await guild.members.fetch()
let membersWithRole = guild.roles.cache.get(ROLE_ID).members

Or you can just filter the members by their role:

let members = await guild.members.fetch()
let membersWithRole = members.filter(member => member.roles.cache.has(ROLE_ID));
about 4 years ago · Juan Pablo Isaza 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