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

430
Vistas
Discord.js: indicador o número de campo de bits no válido: GREMIOS

Estoy teniendo mi primer intento de hacer un bot de Discord. El código es muy básico, solo un bot que registra su propia etiqueta en la consola al iniciarse:

 const Discord = require("discord.js"); const TOKEN = "REDACTED" const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }) client.on("ready", () => { console.log(`Logged in as ${client.user.tag}`) }) client.login(TOKEN)

Sin embargo, al escribir node index.js en el terminal VSCode, aparece el siguiente error:

 PS C:\Users\15055\Documents\Alt Formatter> node index.js C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\util\BitField.js:168 throw new RangeError(ErrorCodes.BitFieldInvalid, bit); ^ RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS. at IntentsBitField.resolve (C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\util\BitField.js:168:11) at C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\util\BitField.js:163:54 at Array.map (<anonymous>) at IntentsBitField.resolve (C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\util\BitField.js:163:40) at Client._validateOptions (C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\client\Client.js:481:41) at new Client (C:\Users\15055\Documents\Alt Formatter\node_modules\discord.js\src\client\Client.js:78:10) at Object.<anonymous> (C:\Users\15055\Documents\Alt Formatter\index.js:9:16) at Module._compile (node:internal/modules/cjs/loader:1112:14) at Module._extensions..js (node:internal/modules/cjs/loader:1166:10) at Module.load (node:internal/modules/cjs/loader:988:32) { [Symbol(code)]: 11 } Node.js v18.4.0

Instalé discord.js con el comando npm i discord.js , así que estoy usando v14.

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

Según la documentación , no puede usar cadenas para nombres de intención, pero las importa desde el paquete, por lo que en su caso algo así como

 const Discord = require('discord.js'); const client = new Discord.Client({ intents: [ Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, ]});

debería hacer el truco.

about 4 years ago · Santiago Gelvez Denunciar

0

En discord.js v14, los indicadores de intención están disponibles en GatewayIntentBits .

 const { Client, GatewayIntentBits } = require('discord.js'); const client = new Discord.Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, ] })

Lista de cambios:

v12/v13 v14
GUILDS GatewayIntentBits.Guilds
GUILD_BANS GatewayIntentBits.GuildBans
GUILD_EMOJIS_AND_STICKERS GatewayIntentBits.GuildEmojisAndStickers
GUILD_INTEGRATIONS GatewayIntentBits.GuildIntegrations
GUILD_INVITES GatewayIntentBits.GuildInvites
GUILD_MEMBERS GatewayIntentBits.GuildMembers
GUILD_MESSAGE_REACTIONS GatewayIntentBits.GuildMessageReactions
GUILD_MESSAGE_TYPING GatewayIntentBits.GuildMessageTyping
GUILD_MESSAGES GatewayIntentBits.GuildMessages
GUILD_PRESENCES GatewayIntentBits.GuildPresences
GUILD_SCHEDULED_EVENTS GatewayIntentBits.GuildScheduledEvents
GUILD_VOICE_STATES GatewayIntentBits.GuildVoiceStates
GUILD_WEBHOOKS GatewayIntentBits.GuildWebhooks
DIRECT_MESSAGES GatewayIntentBits.DirectMessages
DIRECT_MESSAGE_TYPING GatewayIntentBits.DirectMessageTyping
DIRECT_MESSAGE_REACTIONS GatewayIntentBits.DirectMessageReactions
N / A GatewayIntentBits.MessageContent
about 4 years ago · Santiago Gelvez 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