keep_alive
Repls goes to sleep due to inactivity, but to keep it awake, simply host a webserver and ping it.
Installation
Download or copy the keep_alive
file and place it on your repl.
Make sure to keep this file in the same directory as your main
file, alternatively you can place the file in any of the location sys.path
provides or if you really want to you can use sys.path.append(r'home/foo/bar')
to set path and then place it there.
Example use
from discord.ext import commands
from keep_alive import keep_alive
from os import getenv
bot = commands.Bot(command_prefix=">")
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
keep_alive()
bot.run(getenv("TOKEN"))
Here, keep_alive() is called to keep the Repl from going to sleep and this Repl can be pinged to ideally keep it online 24x7.
Additonal features
[1] If you don't want keep_alive
to write anything to your console then set write_to_console = False
and vice versa if you want to.
Console will go from looking like this :
To this :
Squeaky clean.
[2] You can assign text
to any valid data you want and it'll be displayed.
How to ping Repl?
UptimeRobot is a fine option.