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

125
Views
Obtenga todos los usuarios con un rol específico usando discord.js

Recibo RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined. con este código. ¿Puede alguien ayudarme con lo que no está undefined aquí?

Estoy usando discord.js v13.6.0.

 require('dotenv').config(); const token = process.env.bot_token; const { Client, Intents } = require("discord.js") const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.NON_PRIVILEGED, Intents.GUILD_MEMBERS ] }); const prefix = '!getUserByRole'; client.on("messageCreate", (message) =>{ if(!message.content.startsWith(prefix) || message.author.bot || message.author.id) return; const args = message.content.slice(prefix.length).split(/ +/); const roleId = args[1]; message.guild.members.fetch().then((members)=>{ members.filter(mmbr => mmbr.roles.cache.get(roleId)).map(m => { console.log(m.user.tag, m.user.id); }); }) }) client.login(token);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En discord.js v13 Intents.ALL , Intents.NON_PRIVILEGED e Intents.PRIVILEGED se han eliminado para desalentar las malas prácticas. Significa que debe eliminar Intents.NON_PRIVILEGED .

Además, no hay Intents.GUILD_MEMBERS , debería ser Intents.FLAGS.GUILD_MEMBERS . Por lo tanto, deberá actualizar su código de esta manera:

 const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS, ], });
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!