In replit i have a bot in the making with a secret for the token but its erroring and i dont how in any way how to fix it

47 Views Asked by At

heres the code (its just a bot i started making) index.js

const Discord = require("discord.js")
const client = new Discord.Client();

client.on('ready', () => {
  console.log('Logged in!');
});

var TOKEN = process.env['YOUR_TOKEN_HERE']

client.login(TOKEN);

heres the error: the error message. im not gonna type the whole thing here because its too long

the var TOKEN =... used to be const but i figured if i made it a var it would work. it did not and im not even sure what the error is about. other then that i just dont know what to do.

1

There are 1 best solutions below

0
Jaxon Watt On

Your code isn't up to date with the latest discord.js version which I assume you are on v14, refer to the official discord.js guide. Alternatively, refer to the discord.js documentation for ClientOptions, the arguments passed to the constructor (new Discord.Client(ClientOptions here)). This documentation specifies that the intents field is non-optional, which is specified in the error.

As such, you need to specify which intents you are using for example

const client = new Discord.Client({ intents: [GatewayIntentBits.Guilds] });