[Discord] Bot Shutting Down


I’m hosting my Discord bot on Glitch, and I can’t seem to get it to stay on without me leaving the page open. I created the watch.json file as instructed on anidiots.guide with the following code:

“install”: {
“include”: [
“restart”: {
“exclude”: [
“include”: [
“throttle”: 900000

But it still falls asleep/shuts down a few minutes after closing the page. Is there a way to fix this?

Instances will sleep after 5 minutes if nothing has accessed an HTTP end point. You would need to use something like uptime robot to ping it. Keep in mind shutting down instances is partly how they keep this service free :wink: also discord bots tend to use a lot of disk space so you may run up against your disk quota pretty quickly.

1 Like

Here I made a small guide about discord bot hosting on glitch.

This might help you out, and if there is any issues about the guide or any confusion, then you can ping me in discord as well.
https://discord.gg/DsPG6Af here.


Are you sure that’s accurate? I’ve been using this exact example for my bot without any problem.

Adding watch.json is not for keeping the project running, but instead for setting interval of project auto-restart.
So yeah the idiots-guide gitbook gives you some method to keep the bot running, but that will fail when the bots process shuts down, because you are making in-code http request, but the guide i linked above makes http request through external 3rd party website, so that keeps the project online no matter what.


Ah, I see. Thank you for clearing that up.

Awesome guide, thank you! (I also came from the anidiots guide and was so confused)

1 Like

Create an interval that makes a get request to your project every 5 minutes.

Here is an example.

const http = require('http');
const express = require('express');
const app = express();

setInterval(() => {
}, 300000);

the main reason we recommend using a third-party cron/uptime service in lieu of local settimeout calls is that local settimeouts will be reset if we, for some reason, have to restart the servers.


I would do a 280s interval so that there is a little leeway and the app doesn’t shut down an instant before pinging itself. If you use uptime robot as well as this, then the app should never have more than five minutes downtime (and then only when the client is reinstantiated as per jennschiffer's comment).


I did the steps of how to get it to work, but now everytime I am using a command, its answering 17 times…
Any help?

And btw, your discord invite link is expired.

The only reason your bot would be replying would be either you have 17 instances of client running, or you have setup the message handler multiple times.
The best bet is to reset your bot’s token and then try to run the bot and see if it still answers 17 times.

and regarding discord invite link, I though that I might be helping people out with glitch stuffs around discord, especially getting too busy with life, and also because there is a great team here to help out with any issues. :smiley:

1 Like

Also check for any While/For loops that may be repeating the message

use uptime bot or something else
to make your code run 24/7

It would have been better if you had looked through all the replies in the thread.

Lately people are replying in random thread by just looking at the title and without looking at the replies.
(Not attacking you)

But I believe user should look through the post and all the replies before making a reply by just looking at the thread.

If you have a look into the replies, the issue was already solved.

Its not broken, but instead taken down. Because the author of idoits-guide told me to take it down.
And also I am no-longer providing support for glitch over discord.
All because you can get awesome support out here.

So you can simply put your issue out as new thread (But first check if its already reported, solved and so on) and then you will get solution/answer real soon.

1 Like

I have a follow up question to your guide above. I read through post and didn’t see anything related. I followed your steps to the letter, and my bot seems to be timing out[1]? In discord, bot works just fine[2], but when i go to the bot’s page on glitch https:// tigglesbot.glitch. me/ it appears to just time out, and nothing seems to load onto the page. Also, it is telling me that there must be an error in my code or something, which also does not seem to be the case when I check my logs[3]. Any help here? End goal is to just keep this bot online without me having to run nodejs locally every time.

1 - https://cl.ly/3R0d413J0B0t
2 - https://cl.ly/2w3f0a1g1v0l
3 -

ty in advance!

You’re not listening on a port and haven’t defined any routes in your app. It will continue to show the loading icon until that’s resolved. Try adding the following toward the top of index.js

var express = require('express');
var app = express();
app.get("/", (request, response) => {

You can then use the url https://tigglesbot.glitch.me in uptimerobot or another service to keep the bot awake.

1 Like

Here’s the link to my code: https://glitch.com/edit/#!/lying-bus

When I try to add this code to my project at the top of bot.js I get the following error:


  throw er; // Unhandled 'error' event


Error: listen EADDRINUSE :::3000

at Object._errnoException (util.js:992:11)

at _exceptionWithHostPort (util.js:1014:20)

at Server.setupListenHandle [as _listen2] (net.js:1355:14)

at listenInCluster (net.js:1396:12)

at Server.listen (net.js:1480:7)

at Function.listen (/rbd/pnpm-volume/c8e7a0c5-ef98-4267-b4c0-3c915c8f695c/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/application.js:618:24)

at Object. (/app/bot.js:187:5)

at Module._compile (module.js:652:30)

at Object.Module._extensions..js (module.js:663:10)

at Module.load (module.js:565:32)

at tryModuleLoad (module.js:505:12)

at Function.Module._load (module.js:497:3)

at Function.Module.runMain (module.js:693:10)

at startup (bootstrap_node.js:191:16)

at bootstrap_node.js:612:3

Am I adding it in the wrong place?

Looks like you’re already listening on that port.