I’m having trouble with my Discord bot on Replit. I used the Agent feature to build it and it worked great. So I decided to buy Replit Core thinking it would keep my bot running all the time. But I can’t figure out how to make it stay on 24/7. I’ve looked everywhere for an always-on option but can’t find one. I even tried using uptime monitors but they don’t seem to work. Maybe it’s because of how Replit Agent works?
Does anyone know if there’s a way to keep my bot running without leaving the tab open? I feel like I’m missing something obvious. Help would be awesome!
Here’s a quick example of what I’m working with:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('Bot is online')
@client.event
async def on_message(message):
if message.content.startswith('!hello'):
await message.channel.send('Hey there!')
client.run('YOUR_TOKEN_HERE')
I’m just not sure how to keep this running all the time. Any tips?
hey man, ive been there. replit core isnt built for 24/7 hosting. i solved it by using uptimerobot to ping a simple route i added, keeping the bot alive. if it still fails, conside other hosts for discord bots.
I’ve encountered similar issues with Replit Core. While it’s a great platform, it’s not designed for continuous bot hosting. Here’s a workaround that’s worked for me:
Use a free service like UptimeRobot to ping your bot every few minutes. This keeps it active. Add a simple route to your bot code that responds to these pings.
Also, consider using a keep_alive() function in a separate file which can be imported and called in your main script to create a web server that can be pinged regularly.
If you’re still facing issues, you might want to investigate dedicated hosting services for Discord bots, as they generally offer better uptime guarantees. Remember, Replit is primarily for development and may not be optimized for production hosting.
I’ve been in your shoes before with Replit and Discord bots. Here’s what I learned the hard way: Replit Core alone doesn’t guarantee 24/7 uptime for bots. The key is using a combination of Replit’s Always On feature and an external uptime monitor.
First, make sure you’ve enabled the Always On toggle in your repl’s settings. This keeps your repl active even when you’re not editing.
For the uptime monitor, I had success with UptimeRobot. Create a simple HTTP endpoint in your bot (like a ‘/ping’ route) and point UptimeRobot to it. This pings your bot every few minutes, keeping it awake.
Also, consider using environment variables for your token instead of hardcoding it. It’s safer and more flexible.
If you’re still having issues, it might be worth exploring other hosting options like Heroku or a VPS for more reliable uptime. Hope this helps!