How can I make a discord bot stay online even after I close the page?
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)
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!