Discord.js active but not responding

project name: ender-bot-4-0
i am using this line of code:

app.get("/", (request, response) => {
  console.log(Date.now() + " Ping Received");
  response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

but it will not respond, why?


MOD EDIT: formatting

  1. What do you mean saying

it won’t respond

Your code works 100% well in my projects. When the request to a root dir. has sent, server says OK! to a requestser and console.logs to a console about that.

  1. If your problem is that your project being freezed:

Actually, I’m not an expert, but Glitch possibly could freeze your project if no requests were from OTHER IP addresses (not the server’s). It also might be a node.js timers problem or something.
What do you need is called UptimeRobot. This site just sends requests to URL with some interval (you can change). That would 99% keep your project (bot, site, etc.) alive all the time.

what would i put in the request for it to ping it? @jarvis394

This question is in the wrong category as it’s about Express & regular Node.js. Not Discord.js as there is no reference to the discord.js library at all.

Hey @Jonyk56 to set up UptimeRobot to ping your project to keep it alive you would tell UR to ping https://ender-bot-4-0.glitch.me/. @jarvis394 is correct in that the setInterval code isn’t enough to keep your bot always running, since we restart projects at least every 12 hours. The anidiots.guide article that a lot of people use as a resource mentions this briefly as well.

I’m still not sure what you mean by

so I’m not sure this will fully solve your problem.