Getting an error when im trying to node main.js

The code const { Client, Intents } = require('discord.js'); const { token: token } = require('./config.json'); const client = new Client({ intents: [Intents.FLAGS.guilds] }); client.once('ready', () => { console.log('Ready!'); }); client.login(token); The error C:\Users\User\Desktop\Discord Bot\main.js:3 const client = new Client({ intents: [Intents.FLAGS.guilds] }); ^ TypeError: Cannot read properties of undefined (reading 'FLAGS') at Object.<anonymous> (C:\Users\User\Desktop\Discord Bot\main.js:3:47) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 Node.js v18.16.1
6 Replies
d.js toolkit
d.js toolkit12mo 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.
Suspicious Man
Suspicious Man12mo ago
amythanshoe waiting for you
d.js docs
d.js docs12mo ago
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
Suspicious Man
Suspicious Man12mo ago
so what should i fix ? i watched guides so maybe i have the wrong code my bad
d.js docs
d.js docs12mo ago
guide Home: Introduction read more
Suspicious Man
Suspicious Man12mo ago
k, thanks Now it works, thanks a lot !