Keeping my Discord Bot alive 24/7

So I’ve looked through some of the posts here and guides online and I’ve followed everything except that it has a Port variable from the env file in a part of the function to keep the bot going 24/7 but doesn’t list what to set the port to. I’m trying to use the set interval function of the discord.js library but it times out after 5 mins and I think this is the cause. I also have uptime robot going so I’m confident when I say that the project is falling asleep still. Can anyone help me?

Have you setup a HTTP listener in your project? If so could you try visit YOURPROJECTNAME.glitch.me/ping and tell us what it returns? And could you let us know what URI you set the uptime robot ping to

Also, welcome to the glitch forum!

Cannot GET /ping.
https://bothome.glitch.me for the uptime robot.

If this is what you mean by a listener. If not then no. Also thank you for the welcome!
const http = require(‘http’);
const express = require(‘express’);
const app = express();
app.get("/", (request, response) => {
console.log(Date.now() + " Ping Received");
response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get(https://bothome.glitch.me/);
}, 280000);
This is what I’m doing to keep the bot awake

Where have you placed the code? What file, and could you show us the contents of your package.json

The code is in the server.js file which starts up the bot and gets everything ready.

{
“name”: “bots”,
“version”: “1.0.0”,
“description”: “”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“discord.js”: “^11.5.1”,
“discord.js-commando”: “^0.10.0”,
“express”:"^4.17.1"
}
}

These are the contents of the package.json file

I believe i now know your issue, could you lastly show the uptime robot configuration?

Your interval is on 8 minutes, switch it down to 5 minutes and then see if the problems persist (keep an eye on your console)

The interval on uptime robot is set to 5 minutes

Oh right, there doesn’t seem to be anything incorrect with your configuration, and visiting the page does return me a response. Could you try leaving it again, it could just be an unlucky ping time from uptime robot

what do you want me to leave?

I mean letting it sit there for a couple minute, closing project, seeing if it will go offline again

i paused the monitor, added the set interval with 5 min and closed the project and nothing happened. I then turned on the monitor and nothing happened still.

That seems strange, are you getting any received ping messages in console?

Yeah I get those consistently

Could you try setting your interval to 240000 to see if that’ll help?

It works, but its when I set it to 5 min or more that it stops complying. I can’t determine if Glitch is the cause or Discord is the cause.

Projects timeout every 5 minutes of inactivity

Yes but I’m trying to get it so it doesn’t after 5 minutes

That’s how glitch works i’m afraid, you can’t change it, until they implement forever online feature. A project must receive a ping ~5 minutes otherwise it will go offline, and must be reinstated by a web browser or you visiting the project, kind of like cloudflare’s javascript check