In a similar way to this post, the intent GatewayIntentBits.MessageContent
doesn't seem to have a value.
The Privileged Gateway Intents is activated in the Developper portal
Image of my Privileged Gateway Intents
I added the GatewayIntentBits.MessageContent
to my intents
const client = new Client({
intents: [
GatewayIntentBits.GuildMembers,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.MessageContent,
],
});
and i get this error on startup
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/util/BitField.js:172:11)
at /home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/home/pascalaubistrot/dev/Discord-Log/node_modules/discord.js/src/client/Client.js:78:10) at Object.<anonymous> (/home/pascalaubistrot/dev/Discord-Log/index.js:8:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14) {
code: 'BitFieldInvalid'
}
and VScode doesn't recognise the MessageContent flag Image of VScode intents and when I print the value of the intents it is undefined
GatewayIntentBits.GuildMembers : 2
GatewayIntentBits.MessageContent : undefined
And here is a console.log of the GateWayIntentsBits
{
'1': 'Guilds',
'2': 'GuildMembers',
'4': 'GuildBans',
'8': 'GuildEmojisAndStickers',
'16': 'GuildIntegrations',
'32': 'GuildWebhooks',
'64': 'GuildInvites',
'128': 'GuildVoiceStates',
'256': 'GuildPresences',
'512': 'GuildMessages',
'1024': 'GuildMessageReactions',
'2048': 'GuildMessageTyping',
'4096': 'DirectMessages',
'8192': 'DirectMessageReactions',
'16384': 'DirectMessageTyping',
'65536': 'GuildScheduledEvents',
'1048576': 'AutoModerationConfiguration',
'2097152': 'AutoModerationExecution',
Guilds: 1,
GuildMembers: 2,
GuildModeration: 4,
GuildBans: 4,
GuildEmojisAndStickers: 8,
GuildIntegrations: 16,
GuildWebhooks: 32,
GuildInvites: 64,
GuildVoiceStates: 128,
GuildPresences: 256,
GuildMessages: 512,
GuildMessageReactions: 1024,
GuildMessageTyping: 2048,
DirectMessages: 4096,
DirectMessageReactions: 8192,
DirectMessageTyping: 16384,
GuildScheduledEvents: 65536,
AutoModerationConfiguration: 1048576,
AutoModerationExecution: 2097152
}
Version of discord.js: version: '14.11.0
Version of discord API: APIVersion: '10
Edit: I found out that i can pass the bitfields directly and the bot work fine and i can read the content of the message
const client = new Client({
intents: 101917
});
I didn't find anyone else having this problem apart from this this post which was resolved but the solution didn't work for me.