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

170
Views
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 answers
Answer question

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 Report

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 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!