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

181
Vistas
How to set a role for a member list? discord.js v13

const membersWithRoleRadiant = message.guild.roles.cache.get('957714551011442781').members

membersWithRoleRadiant.roles.set(['955804233284878367']);

TypeError: Cannot read properties of undefined (reading 'set')

I received a list of participants with a specific role, I would like to set a different one for each.

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

0

Note: This is written for Discord.js v13.4.0.


.roles is not a property

Your issue is that you are calling the roles property on a Collection of GuildMember. This doesn't work because Collections are a Map but modified. You would have to perform .each() and apply the role that way. It'd look something like this:

membersWithRoleRadiant.each(member => member.roles.set(['IDHere']);

A small advisory as well. You should be careful when updating roles for a lot of users at once. This can be considered API spam which will cause Discord to rate limit or shut down your bot.

Reconsider using .set()

If you are only adding or removing roles, I strongly discourage the usage of .set(). That method will remove all their roles and replace it with the ones you have supplied. If you are adding roles, use the .add() method. Use the .remove() method when removing roles.

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