Ask coding questions

← Back to all posts
How can I make a discord bot stay online even after I close the page?
hillsam001 (25)

I have a discord bot here that I made just as a placeholder for my discord server. Everything works fine, but when I close the tab it goes offline! How can I make it stay online?

Answered by a5rocks (819) [earned 5 cycles]
View Answer
Comments
hotnewtop
a5rocks (819)

https://www.codementor.io/garethdwyer/building-a-discord-bot-with-python-and-repl-it-miblcwejz#keeping-our-bot-alive

Follow the steps here to keep it alive.

EDIT: Please make sure your token is secure. Regenerate it, and then use a .env file to keep it secure. If people get your token, they can, for example, delete all the channels in every server it has access to. (if you don't want to secure your bot, just make sure it doesn't have the permissions to do anything disastrous)

hillsam001 (25)

@a5rocks Okay, thanks for the tip.

[deleted]

@a5rocks thank you so much! Ur a life saver!

tdhthekid (0)

mate your token is public

hillsam001 (25)

@tdhthekid it's fine, i don't use the bot anymore as it was just for testing

Cerberus_75 (16)

going off what @a5rocks said after you set up your flask server you can use uptime robot to constantly ping your bot and keep it "alive" for much longer (there are downtimes, but its a start). You can use this tutorial made by @badvillain01: https://repl.it/talk/learn/How-to-use-and-setup-UptimeRobot/9003. Good Luck!