My Discord bot doesn't automatically run

I use Glitch for Discord bot purposes, but ever since I used the discord.js tutorial for command handling, i’ve always had to manually open bash and execute node. When I close the bash tab, node will always close. Am I doing something wrong? I use Uptime Robot and a script that submits all my changes every fifteen minutes, to avoid ratelimiting. (On top of this, when I try to open my Glitch project’s website, it’s stuck on “Waking up” or “Starting”)

Hello @Dannybyte,

Can you please show me your uptime robot configuration.

Yeah, sure.

EDIT: Uptime Robot can’t seem to connect to the website, and when I go to the website, it’s stuck on waking up. I feel like this is the problem.

Ok, I can see that the problem is most likely because you do not have anything running on the glitch port. You have to setup a webpage to get this to work. These steps will work:

var express = require('express');
var app = express();
var listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});
app.use(express.static('public'));
app.get('/', function(request, response) {
  response.sendFile(__dirname + 'index.html');
});

Create a file called keepOnline.js and put that code inside it. Then go to your main file, and put require('/app/keepOnline.js') On any empty line that is not inside any event or anything like that.


MOD EDIT: corrected method name

1 Like

Okay, thank you for that! I’ll try it.

1 Like

I’ve just tried it, but the require function seems to be undefined.

Hey @Dannybyte I’m not sure which of the require functions were reporting as undefined, but I’ll note that there was a typo in @Callum-OKane’s last post that might have caused issues if you copy/pasted from that post.

If you care to share your project name folks might be able to give more specific advice.

My project name was already on my screenshot but i’ll list it again.

https://rich-goldfish.glitch.me

1 Like

Can you invite me to the project, I do not see why this might be happening, but I might not see the problem with what I provided you and could be more helpful to see it from inside the project!

EDIT: I see what the problem was, I could not see afterwards because Cori edited and I had not noticed at first, can you retry the require code I provided above, and it should work now!

Alright! I’ll PM you the link.

Ok, I have fixed the parse error you had aswell, which was just a coma (,) incorrectly placed. Everything else is working now using the code I provided above!

Alrighty. Thanks for your help.

1 Like

No problem, have a great day!

1 Like