Code not working

Question: I tried removing that comma in position 19 but seems like the code is buggy, can anyone help me?

Repl link:

const express = require("express");
const app = express();

app.listen(3000, () => {
  console.log("Project is running!");

  app.get("/", (req, res) => {
  res.send("Hello world");

const Discord = require("discord.js");
const client = new Discord.client({intents: ["GUILDS", "GUILD_MESSAGES"]});

client.on("message"), message => {
  if(message.content === "ping") {"pong");


Just so you know, you have one file named index.js and the other index .js (with the space). Make sure you are adding your changes to the index.js file (without a space) because that is the one that Replit runs by default.

Also, you need to update the following from line 15:

client.on("message"), function(message) {
  if(message.content === "ping") {"pong");

I did that and then It said the same comma is missing but now fixed, afterwards it now says unexpected end of input on line 21

The callback is a parameter, so it should be inside ().


client.on("message", function(message) {
  if(message.content === "ping") {"pong");

Or if you want arrow functions

client.on("message", (message) => {
  if(message.content === "ping") {"pong");
1 Like

Parentheses here are not needed…

True, but I always add () in arrow functions.


Discord.js does not use “message” anymore. You should use “messageCreate”.

client.on("messageCreate", message => {
  if(message.content === "ping") {"pong");

Also, change new Discord.client() to new Discord.Client() . Javascript is case sensitive.

Another thing is that client.login(process.env.token); is used when you have a .env file. Replit uses Secrets so you better change this too.


you can still use process.env.<SECRET_KEY>, but I prefer to have a secret with key DISCORD_TOKEN which means that I do just client.login(); with no arguments.

Your error would be that you haven’t closed the app.listen callback properly. In future please paste in the relevant errors in a code block. But I would recommend going without express, since the webserver is just for keep-alive and you could replace it (lines 2-7) with

  .createServer((_, res) => res.writeHead(204).end())

For the next issue you’ll get: see


I ended up coding in the similar way before seeing all this on visual studio code, bot is ready but now it keeps going offline, gonna try and add that code here too