Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

583
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda