I'm having an issue with importing the intents for my discord bot. (It was working and I believe I updated my discord.js version, tried downgrading and still couldnt get it to work so now im trying to get the new intents to work.)
This is how I have intents
const { Client, Intents } = require('discord.js');
const client = new Client({
intents: [
Intents.GUILDS,
Intents.GUILD_MESSAGES,
Intents.GUILD_MESSAGE_REACTIONS
]
});
I get this error
Intents.GUILDS,
^
TypeError: Cannot read properties of undefined (reading 'GUILDS')
I have tried using different versions of discord.js and changing it from Intents to GatewayIntentBits like the discord.js docs says but then I get this error
throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
^
TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
My original code was
const client = new Discord.Client({
intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"],
allowedMentions: ["users"]
});
and was working.
Does anyone know how to fix this or what version to downgrade for node and discord.js to get this working again.
Current Verions: Discord.js: 14.7.1 Node: 19.3.0
**EDIT I have updated my code to what discord.js refrences
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
and am now receiving this error. Intents are also enabled in the bot.
throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
^
TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at Client._validateOptions (/home/runner/Discord-Bot/node_modules/discord.js/src/client/Client.js:489:13)
at new Client (/home/runner/Discord-Bot/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/home/runner/Discord-Bot/member-count.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/runner/Discord-Bot/index.js:22:21) {
code: 'ClientMissingIntents'
}
Node.js v19.3.0
exit status 1