Skip to main content

Why doesn't my discord bot get online when I type node main.js in command promp?

This is my package.json file:

{
  "name": "bot",
  "version": "1.0.0",
  "description": "My  discord Bot",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Undefined Human",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^14.3.0"
  }
}

Here is the main.js file:

const Discord = require('discord.js');

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



client.once('ready', () => { 
    console.log('GhxstedCloudz is online');
});




client.login('my bot token');

and here is the error I get when I type node . or node main.js in the terminal:

C:\Users\Administrator\Desktop\bot\main.js:5
        Discord.Intents.FLAGS.GUILDS,
                        ^

TypeError: Cannot read properties of undefined (reading 'FLAGS')
    at Object.<anonymous> (C:\Users\Administrator\Desktop\bot\main.js:5:25)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47
Via Active questions tagged javascript - Stack Overflow https://ift.tt/9oyPNCs

Comments