Discord Bot on Replit Keeps Shutting Down

Hey everyone! I’m new to coding and made a Discord bot for fun on Replit. It’s pretty simple, just sends embeds for commands. I set up a command handler too. But I’ve got a problem - the bot keeps going offline. At first, it lasted a few hours, now it’s down after 20 minutes. No errors, just stops running.

I’ve tried the usual fixes like using uptimerobot and keepAlive(). Uptimerobot shows no connection loss. I even made a test bot with just a ping command, and it’s been fine for days.

I’m wondering if my 105 commands are too much for Replit’s free resources. The bot shuts down even when no one’s using it.

Anyone got ideas on how to keep it running? Thanks!

heya tom! sounds like u might be hittin replit’s resource limits. 105 commands is a lot for free tier. maybe try splittin ur bot into smaller parts or use a diff hosting service? heroku’s got a free tier that could work better. good luck mate!

I’ve encountered similar issues with Replit’s free tier. While 105 commands might not seem excessive, the resource allocation can be unpredictable. Have you considered monitoring your bot’s memory usage? It’s possible that even when idle, your bot is consuming more resources than expected. You might want to implement some optimization techniques, such as caching frequently used data or lazy-loading commands. Alternatively, if you’re committed to keeping all features, you might need to explore paid hosting options or dedicated VPS services for more stable performance.

Hey Tom, I’ve been down that road with Replit too. One thing that helped me was implementing a more aggressive garbage collection strategy. Try adding periodic calls to gc.collect() in your main loop. This can help manage memory usage, especially with a large number of commands.

Another trick I found useful was to use a ‘lazy loading’ approach for your commands. Instead of loading all 105 commands at startup, you could load them on-demand when they’re first called. This significantly reduced my bot’s initial memory footprint.

If these don’t work, you might want to look into AWS Lambda or Google Cloud Functions. They offer generous free tiers and can handle bots pretty well. Just be prepared for a bit of a learning curve if you’re new to cloud services.

Hope this helps! Let us know how it goes.