Skip to content
Sign upLog in
← Back to Community
Discord Bot Goes Offline After An Hour Even Though Uptime is Hooked Up
Profile icon
[deleted]

Hi there! I have been working on a discord bot, and after an hour, instead of staying online, the bot will just go offline even though I have it linked to Uptimerobot. Is there anything that I’m doing wrong?

Voters
Profile icon
tobydog0501
Comments
hotnewtop
Profile icon
NoelB33

Would you mind trying this?
In your server.js: put this:

const express = require('express'); const server = express(); server.all('/', (req, res)=>{ res.send('Your bot is alive!'); }); function keepAlive(){ server.listen(3000, ()=>{console.log("Server is Ready!")}); } module.exports = keepAlive;

And at the top of index.js, put this:

const keepAlive = require('./server‘);

And at the bottem or index.js, put this before the client.login():
keepAlive();
If this works you can mark this answer as correct. If not tell me.
Source: https://repl.it/talk/learn/Hosting-discordjs-bots-on-replit-Works-for-both-discordjs-and-Eris/11027

Profile icon
[deleted]

@NoelB33
when I do that, in index.js there is an error

Profile icon
NoelB33

Uhh you just totally messed up your files, delete everything in index.js and copy everything in server.js over into index.js. After that, copy everything from server stuff.js into server.js and delete server stuff.js

@JollyJack8

Profile icon
[deleted]

@NoelB33
sorry I just put in a different file because I put my token in and I didn't want to share it. The original file is back. What should I do now?

Profile icon
NoelB33

Delete everything in server.js, and then get rid of line 114 in index.js. Then, Do what I said in my first comment.

@JollyJack8

Profile icon
Coder100

Hello, do you have an HTTP server with the bot?

Profile icon
[deleted]
Profile icon
NoelB33

Can you link a repl?

Profile icon
[deleted]

@NoelB33
linked it