Discord Bot Offline No error message Uptime says its online but discord says otherwise

I hosted a bot on glitch.com(I know its not supposed to be a vps). I put in const server = require('./server.js'); above everything else in index.js and put const https = require('https'); const express = require('express'); const app = express(); app.get("/", (request, response) => { console.log(Date.now() + " Ping Received"); response.sendStatus(200); }); setInterval(() => { https.get(`https://enshrined-broccoli.glitch.me/`); }, 6000) const listener = app.listen(process.env.PORT, function() { console.log('Your app is listening on port ' + listener.address().port); }); in server.js

It was supposed to ping the bot but discord says that the bot is offline and uptime and glitch says it is up and live. Can someone please help me?

Also, I have another bot that has this as its pinger

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(() => {
  https.get(`https://nervous-gerbil.glitch.me`);
}, 6000);```

Its discord.js btw

Hi @Bobthemoose, welcome to Glitch!

You bot’s pubic interface does indeed appear to be up and running, or at least it responded immediately when I called it, so it seems like your UptimeRobot and Express configuration is working properly. What are you seeing that indicates that it’s down? Does it ever appear to be up?

Also, for whatever it’s worth, having a properly-configured UptimeRobot setup means that the setInterval() portion of your code is unnecessary, and that by itself will never keep your bot alive 24/7.

ok, it has been working for the last week. I only changed it to uptime robot because I had to refresh it every day

When I look at BobBot, it appears invisible/offline on the discord and does not respond to any commands.
@cori

Ok looking at the code behind enshrined-broccoli and I think the problem is this part of your package.json:

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },

when your project starts up it runs server.js, which exposes your UptimeRobot endpoint so the bot looks like it’s “up” from that perspective. However all your bot’s code is in index.js.

Since index.js require()s server.js you should be able to change your package.json to run node index.js for it’s start script and the bot should start responding and UptimeRobot would still work as expected.

Also it looks like you’ve got the Debugger running. It may not have any effect, but it wouldn’t hurt to stop it before testing your bot. Use the stop sign in the photo below.

image

@cori Thanks a lot! I appriciate it!