Can anyone help me with the discord intents

i dont know what this error means:
/home/container/index.js:40
intents: [Discord.Intents.FLAGS.GUILDS,
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (/home/container/index.js:40:29)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
at node:internal/main/run_main_module:23:47
/home/container/index.js:40
intents: [Discord.Intents.FLAGS.GUILDS,
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (/home/container/index.js:40:29)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
at node:internal/main/run_main_module:23:47
39 Replies
d.js toolkit
d.js toolkit•11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
NNKtv28
NNKtv28•11mo ago
code:
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
intents: [Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.GUILD_MESSAGE_TYPING,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.DIRECT_MESSAGE_TYPING
],
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
intents: [Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.GUILD_MESSAGE_TYPING,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.DIRECT_MESSAGE_TYPING
],
now i changed the Intents.FLAGS to GatewayIntentBits and i get a complete different error
/home/container/node_modules/discord.js/src/util/BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:172:11)
at /home/container/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/home/container/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/home/container/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/home/container/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/home/container/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/container/index.js:30:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14) {
code: 'BitFieldInvalid'
}
Node.js v19.0.0
/home/container/node_modules/discord.js/src/util/BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:172:11)
at /home/container/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/home/container/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/home/container/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/home/container/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/home/container/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/container/index.js:30:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14) {
code: 'BitFieldInvalid'
}
Node.js v19.0.0
d.js docs
d.js docs•11mo ago
Tag suggestion for @nnktv28: RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined - All SCREAMING_SNAKE_CASE enums have been changed to PascalCase - Intents: Intents.FLAGS.GUILD_MESSAGES -> GatewayIntentBits.GuildMessages - Permissions: Permissions.FLAGS.SEND_MESSAGES -> PermissionFlagsBits.SendMessages
NNKtv28
NNKtv28•11mo ago
i dont have permissions i have partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
geisterfurz007 (gone till 14th)
Point is: Discord.Intents doesn't exist anymore if you updated to discord.js 14. Change it to Discord.GatewayIntentBits instead. Further, you have to convert them all to PascalCase, so GUILD_MEMBERS becomes GuildMembers, GUILD_BANS becomes GuildBans, etc.
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessagesReactions,
],
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessagesReactions,
],
this is how it is now
geisterfurz007 (gone till 14th)
<:PES_Yeeeees:601747554522365952>
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
so instead of partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'], to do Partials.Channel: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'], ?
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
ohhh partials: ['Partials.Message', 'Partials.Channel', 'Partials.Reaction', 'Partials.GuildMember', 'Partials.User'], ? like that?
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
geisterfurz007 (gone till 14th)
Discord.Partials.Message in your case probably since you are importing it all at once
NNKtv28
NNKtv28•11mo ago
oh okay so directly partials: [Discord.Partials.Message],
geisterfurz007 (gone till 14th)
<:PES_Yeeeees:601747554522365952> Yup
NNKtv28
NNKtv28•11mo ago
updated code:
partials: [Discord.Partials.Message],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessagesReactions,
],
partials: [Discord.Partials.Message],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessagesReactions,
],
i still get the bits error T_T
geisterfurz007 (gone till 14th)
What bits error was that again?
NNKtv28
NNKtv28•11mo ago
/home/container/node_modules/discord.js/src/util/BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:172:11)
at /home/container/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/home/container/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/home/container/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/home/container/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/home/container/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/container/index.js:27:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14) {
code: 'BitFieldInvalid'
}
/home/container/node_modules/discord.js/src/util/BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:172:11)
at /home/container/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/home/container/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/home/container/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/home/container/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/home/container/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/home/container/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/container/index.js:27:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14) {
code: 'BitFieldInvalid'
}
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
geisterfurz007 (gone till 14th)
DirectMessagesReactions should be DirectMessageReactions (there is one s too much after Message) Goddamn it 😄
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
nope, still get the same error
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
const client = new Discord.Client({
fetchAllMembers: false,
restTimeOffset: 0,
failIfNotExists: false,
shards: "auto",
allowedMentions: {
parse: ["roles", "users"],
repliedUser: false,
},
partials: [Discord.Partials.Message],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessageReactions,
],
presence: {
activities: [{ name: `${config.status.text}`.replace("{prefix}", config.prefix), type: config.status.type, url: config.status.url }],
status: "online"
}
});
const client = new Discord.Client({
fetchAllMembers: false,
restTimeOffset: 0,
failIfNotExists: false,
shards: "auto",
allowedMentions: {
parse: ["roles", "users"],
repliedUser: false,
},
partials: [Discord.Partials.Message],
intents: [Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildBans,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildWebhooks,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildPrecences,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.DirectMessageReactions,
],
presence: {
activities: [{ name: `${config.status.text}`.replace("{prefix}", config.prefix), type: config.status.type, url: config.status.url }],
status: "online"
}
});
geisterfurz007 (gone till 14th)
There is another typo in GuildPresences
NNKtv28
NNKtv28•11mo ago
nope, saved and reloaded the bot ohh mb XD
geisterfurz007 (gone till 14th)
And don't forget to add your remaining partials in the same manner :)
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
? wdym sharding?
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
thats for music stuff right?
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
ohh then nope its a private bot
Unknown User
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
NNKtv28
NNKtv28•11mo ago
oh ok thxx what are erela events for?? cause i see couple bots use it
geisterfurz007 (gone till 14th)
If it's this erela, reads like something that was used to support music playing? 🤔 But the project was archived 8 months ago by the looks of it: https://github.com/MenuDocs/erela.js
NNKtv28
NNKtv28•11mo ago
ohh ok yeah i def dont need that XD how can i find where the typo is here
node:internal/modules/cjs/loader:1230
throw err;
^
SyntaxError: /home/container/languages/en.json: Bad control character in string literal in JSON at position 41804
at parse (<anonymous>)
at Module._extensions..json (node:internal/modules/cjs/loader:1227:39)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/container/index.js:61:50)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
Node.js v19.0.0
node:internal/modules/cjs/loader:1230
throw err;
^
SyntaxError: /home/container/languages/en.json: Bad control character in string literal in JSON at position 41804
at parse (<anonymous>)
at Module._extensions..json (node:internal/modules/cjs/loader:1227:39)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/container/index.js:61:50)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
Node.js v19.0.0
it says position 41804 but what line is that?? nvm found it i get this error now
=== UNHANDLED REJECTION ===
Reason: Error: Used disallowed intents
at WebSocketShard.onClose (/home/container/node_modules/@discordjs/ws/dist/index.js:1066:15)
at WebSocket.emit (node:events:513:28)
at WebSocket.emitClose (/home/container/node_modules/ws/lib/websocket.js:258:10)
at TLSSocket.socketOnClose (/home/container/node_modules/ws/lib/websocket.js:1264:15)
at TLSSocket.emit (node:events:525:35)
at node:net:298:12
at TCP.done (node:_tls_wrap:587:7)
=== UNHANDLED REJECTION ===
=== UNHANDLED REJECTION ===
Reason: Error: Used disallowed intents
at WebSocketShard.onClose (/home/container/node_modules/@discordjs/ws/dist/index.js:1066:15)
at WebSocket.emit (node:events:513:28)
at WebSocket.emitClose (/home/container/node_modules/ws/lib/websocket.js:258:10)
at TLSSocket.socketOnClose (/home/container/node_modules/ws/lib/websocket.js:1264:15)
at TLSSocket.emit (node:events:525:35)
at node:net:298:12
at TCP.done (node:_tls_wrap:587:7)
=== UNHANDLED REJECTION ===
what are disallowed intents??