How to keep your discord bot running 24/7 without the Hacker Plan
LeviathanCoding (1606)

I personally don't make discord bots but I helped my friend make one run all the time and it can be done in two simple steps.

Once you finish your discord bot, attach a simple web server into it. If using discord.js, set up a simple "Hello World" web server and if using, simply make a flask server.


Add a simple express server at the end of the code.

//...Discord Bot Code Above ^^

const express = require('express')
const app = express();
const port = 3000;
app.get('/', (req, res) => {
  res.send('Hello World!')
app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)

Make sure you run npm install express in the terminal!!

How to do it in python.

To set up a flask server, simply add this code to the end of your python file:

#python discord bot code above ^^
from flask import Flask
app = Flask(__name__)
def index():
  return "Bot up and running"
if __name__ == '__main__':"",debug=True,port=8080)

also, run pip install flask in the terminal.

After that's done, your repl will still fall asleep. To fix that, make an account at uptimerobot and add your repl domain or link. It should look like

After that, make sure you RUN your repl

and everything should be up and running.

You are viewing a single comment. View All
MagnusOelsner (0)

Where Do I add This Line Of Code For Java