Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

582
Views
Invalid Bot Token, discord.js

I'm new to discord.js and I have no clue why I'm getting this error:

Uncaught Error [TOKEN_INVALID]: An invalid token was provided.

my bot.js file

    const { Client, Intents } = require('discord.js');
    const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
    
    client.on('ready', () => {
        console.log(`Successfully Logged in as ${client.user.tag}!`);
    });
    
    client.login(process.env.TOKEN);

.env file

TOKEN='my Bot token here'

I'm 100% sure that my bot token is correct/valid, I have also tried revoking it and copy-pasting the new token several times, but I still get the same error... I have searched up nearly everywhere on the net and I still haven't found a solution to my problem.

package.json file

{
  "dependencies": {
    "discord.js": "^13.6.0",
    "dotenv": "^16.0.0"
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Did you initialize the env to be used in your file?

You will have to use dotenv package.

Put require('dotenv').config() at the top of your file and you would be good to go

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!