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);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, ], });