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

227
Vistas
Cómo agregar un rol a un usuario

He mirado varias guías en línea y en su mayoría usan este comando

 let role = message.guild.roles.cache.find(r => r.id === "Role ID"); // The member you want to add the role to let member = message.mentions.members.first(); // Add role to the member member.roles.add(role); // Or add it to yourself message.author.roles.add(role);

Intenté esto mucho y esta es mi implementación de ese código.

 if (message.member.roles.cache.some(role => role.name === "Co-Owner" || role.name === "Operator")) { if (command == "birthday") { const mention = message.mentions.users.first() || client.users.get(args[0]); var role = message.guild.roles.cache.find(role => role.name === "BIRTHDAY POG"); if (mention.roles.cache.some(role => role.name === "BIRTHDAY POG")) { message.reply("The user has already the role, the role will now be removed"); mention.roles.remove(role); } else { mention.roles.add(role); message.reply("The role has been added to `" + mention.username + "`"); client.guilds.cache.get('731368965963513936').channels.cache.get('778124805135663104').send(message.author.username + " has used the command Birthday to " + mention.username); message.reply("Use the same command with the person to remove the role"); } } }

Este comando debería agregar el rol de cumpleaños al usuario mencionado pero no puedo hacerlo funcionar, da este error

 if (mention.roles.cache.some(role => role.name === "BIRTHDAY POG")) { ^ TypeError: Cannot read property 'cache' of undefined

¿Alguien me puede ayudar?

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

0

Echa un vistazo a esto https://stackoverflow.com/a/63979077/15107810

Pero básicamente, necesitas cambiar

 message.mentions.users.first() || client.users.get(args[0]);

a

 message.mentions.members.first() || message.guild.members.cache.get(args[0])
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