Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

507
Views
Asignación masiva de roles a los usuarios (discord.js v13)

Este código asigna roles a una lista de usuarios separados por una nueva línea, pero solo usuarios en caché. ¿Cómo puedo implementar message.guild.members.fetch() en este código para asignar roles a todos los usuarios?

 //command !roleAssign @role name#1234 name#2234 name#3234
 const roleAssign = function(message){ const Role = message.mentions.roles.first(); // split by new line const users = message.content.slice(prefix.length).split(/\r?\n/).slice(1); const success = []; users.forEach(user => { const u = client.users.cache.find(u => u.tag === user); if(u){ const userId = u.id; // person with the userID let person = message.guild.members.cache.get(userId); // give role to person try{ person.roles.add(Role) } catch(e){console.error(e)}; if(person.roles.cache.has(Role.id)){ success.push(user); } } }); message.channel.send(`Added role ${Role.name} to\n${success.map(user => user).join("\n")}`); }

Intenté esto pero obtuve TypeError: Cannot read properties of undefined (reading 'find')

 message.guild.members.fetch().then((members)=>{ message.cache.find(u => u.tag === user); })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let members = await message.guild.members.fetch() members.filter(user => !user.bot).tap(message.guild => { })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!