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

171
Visualizações
Discord bot is not coming online

My discord bot is not coming online. Here is my .js file

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

const TOKEN = "my-token-is-here";

client.on("message", message => {
  if (message.content === "Hello Discord Bot") {
    message.channel.send("Hi There!");
  }
  {
    console.log("Bot Is Ready!");
  }
});

client.login(TOKEN)

The error I am getting is

SyntaxError: Unexpected token ?
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Based on your comments you've installed Discord.js version 13.1.0 but your NodeJS version is lower than 16.6. There are two options for you to solve this problem.

Option 1 (most recommended)

You'll need to update your NodeJS version to 16.6 or higher. You can do this by downloading a version of NodeJS at the NodeJS website and complete the setup again.

Once you've completed the setup you should be able to run your Discord bot again.

Option 2

If you don't want to update your version you can install Discord.js version 12.5.3. This version is not as stable as version 13.1.0 is but it is possible. You can do this by using the npm command npm install discord.js@12.5.3. After installing the 12.5.3 version you should be able to run your bot again.


Also like Luca Mertens noticed your breaks are incorrectely. You should replace them to

client.on('ready', () => console.log(`Bot is ready`));

client.on("message", message => {
    if (message.content === "Hello Discord Bot") {
        message.channel.send("Hi There!");
    }
});
about 4 years ago · Juan Pablo Isaza Relatório

0

You should never post any private tokens publicly. Be sure to make a new token on the Discord-Developer-Portal and don't continue using this one!

To your question: It seems like the lines

{
    console.log("Bot Is Ready!");
}

cause the syntax error. You probably want to move that statement into it's own event handler for the event "ready" (triggered when DiscordJs has finished setting up the bot-client for you).

client.on("message", message => {
  if (message.content === "Hello Discord Bot") {
    message.channel.send("Hi There!");
  }
});

client.on("ready", () => {
    console.log("Bot Is Ready!");
});

client.login(TOKEN)
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