Discord bot code doesn't work

Here’s my code:

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"){
    message.channel.send("pong")
  }
})

client.login(process.env.token);

Seeing as the app.listen call is at the beginning of your code, that would be why. Nothing after that line gets run.

2 Likes

Okay, but how do I fix it?

You could simply remove that section of your code.

A post was split to a new topic: I need help making an action game