'How do I close a port in Discord.js?

In my previous question, I was recommended to try reconnecting to the port, and I have researched and have not been able to find out how. How can I do this?

    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("messageCreate", message => {
  if(message.content === "jobs") {
    message.channel.send("fortnite battle royale");
  }
})

client.on("messageCreate", message => {
  if(message.content === "ping") {
    message.channel.send("pong, you idiot, you should know the rest");
  }
})

client.on("messageCreate", message => {
  if(message.content === "pls dont help") {
    message.channel.send(message.author.toString() + " " +"ok, i wont, all you had to do was ask... also dank memer stole this command");
  }
})


client.on("messageCreate", message => {
   if (message.author.bot) return;
  if(message.content.includes("dream")) {
   var msgnumber= (Math.floor((Math.random() * 2) + 1));
    console.log(msgnumber);
    if (msgnumber===1) {
         message.channel.send("did someone say dream!?");
    } else if (msgnumber===2) {
         message.channel.send("why we talkin' about dream... huh!?");
    }
  }
})

client.on('messageCreate', message => {
  if (message.content === '!ping') {  
    message.channel.send(`🏓Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`);
  }
});

client.on("messageCreate", message => {
  if(message.content === "username") {
    message.channel.send(message.author.username);
  }
})

client.on('ready', () => {
  console.log('Bot is online!');
  client.user.setActivity('not being entertained', {type : 'PLAYING'} )
})

client.login(process.env.token);

Comment that suggested this: My bot has been offline with no error, it was working yesterday



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source