This is my code:
import { Client } from 'discord.js';
const bot = new Client();
bot.on('ready', () => console.log('${bot.user.username} is online'));
bot.login('MyToken');
This is the error i get. I have node 14.17.5 installed.
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\Users\jayrc\OneDrive\Documents\Coding\Discord\illuminate\node_modules\discord.js\src\client\Client.js:544:13)
at new Client (C:\Users\jayrc\OneDrive\Documents\Coding\Discord\illuminate\node_modules\discord.js\src\client\Client.js:73:10)
at file:///C:/Users/jayrc/OneDrive/Documents/Coding/Discord/illuminate/src/bot.js:3:13
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5) {
[Symbol(code)]: 'CLIENT_MISSING_INTENTS'
Assuming you're using the most recent version (v13) of discord.js, they specify on this page that you need node v16.6 or newer.
More specifically, v13 of discord.js introduced many changes to their client object, one of which was the introduction of intents.
Your bot needs to specify what its intents are within the constructor of the client object, like the getting started example on line 3.
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
Obviously which intents you need will depend on what your bot does. You can read up on intents on discord's official developer docs.