-1

I want to create a status page for my discord bot to let other users see if my bot is currently running or if it is offline. I use UpTimeRobot for that. But I saw that the only options to check if my bot is running are HTTP(s), Keyword, Ping, and Port. So my question is now, how can uptimerobot check, if my bot is online with one of the 4 methods? Which would be the easiest way and what do I need to do to let this work?

I tried many different things at searching, but couldn't find a solution.

Razzer
  • 492
  • 1
  • 4
  • 29

2 Answers2

2

It comes down to how you are hosting the Discord Bot.

Easiest way is probably to have a web server running somewhere, and have your Bot send a request every X minutes to let it know that it's still alive.

Out of the four options: HTTP(s), Keyword, Ping and Port - HTTP is probably the simplest, but you might not even need UpTimeRobot (depending on how nice looking you want the status page). But it would require you to run the Web Server and the Discord Bot on the same system. See this answer for more details.

J-Stark
  • 51
  • 3
  • How can i send such a request and how can my server accept it? – Razzer Sep 24 '21 at 23:27
  • A very basic way could be the Discord bot making a GET request to www.yourwebsite.com/updateDiscordBot.php On that page, you can update a database with the current time. So whenever it is visited, the bot is listed as "alive". Then on www.yourwebsite.com/status.php you check your database to see when the bot last responded, and you display that to the users. Could also combine it with UptimeRobot. Have the status.php say "Alive", and then UptimeRobot checks www.yourwebsite.com/status.php looking for the keyword "Alive". – J-Stark Sep 25 '21 at 08:52
1

You can use replit for your bot.Upload the files,rename your bot's main program to main.py,and then add this to a new blank file(name the file keep_alive):

from flask import Flask
from threading import Thread
app = Flask("")
@app.route("/")
def home():
    return "Hello. I am really alive!"
def run():
    app.run(host="0.0.0.0",port=8080)
def keep_alive():
    t = Thread(target=run)
    t.start()

Add the lines

import keep_alive
keep_alive.keep_alive()

right before the client.run() call.
Click the run button at the top.You should see a panel open at the top right of the screen saying "Hello. I am really alive!". Copy the address in the address bar above.Then set the UptimeRobot monitor to point to that website.

NOTE:This method is completely free.You don't need the paid version of the replit account.While it says the bot will stop after you close the browser tab, it actually closes after 1 hour of network inactivity. As long as UptimeRobot's ping interval is less than 1 hour,you are fine.

  • I'm getting the warning `WARNING: This is a development server. Do not use it in a production deployment.` – Razzer Sep 25 '21 at 17:54
  • Don't worry.I use this.Just ignore this –  Oct 03 '21 at 05:05
  • @Razzer This is because Flask is in production mode. Since you aren't really serving any (useful) data, just "hi,I'm really alive!", you can ignore this. –  Dec 19 '21 at 01:46