#bot restart command - discussion

1 messages · Page 1 of 1 (latest)

humble lance
#

An old friend of mine built me a bot restart command that lived in my main bot file. This was some time ago and I no longer have it, but I was wondering if others have created a command, or script, that allows them to restart their bot on demand. The one my friend built for me would restart the bot, but wouldn't kill the current bot instance but instead would just start a new one to the point that the bot couldn't figure out which instance to respond to when a command was executed. Has anyone found a way to restart their bot on demand without having to use ctrl+c in the terminal and restarting it manually?

gaunt wolf
#

I'll never understand the need for something like this.
Build it to be online 24/7. The need to restart the bot should be so little that spending the time to create a command to do so is a waste.

humble lance
#

it is being built to be online 24/7. This is meant more for development. Instead of having to restart the bot manually every single time, I can just run a command to do it all. Idk. thought it was a fun idea.

gaunt wolf
#

You could also just set reload=True in the bot constructor and it would reload any cogs that detect changes.

humble lance
#

didn't know that was a thing. What would be an example of that?

gaunt wolf
#

But, the reality of a command vs ctrl+c, up, enter is not really that inconvenient

humble lance
#

like bot = commands.Bot(cp=cp, intents=intents, reload=True)?

gaunt wolf
#

commands.Bot(..., reload=True)

#

But this only seems to work when cogs are loaded properly via bot.load_extension

humble lance
#

that sounds like a neat thing, but like would it try and reload every single time I type a new character?

gaunt wolf
#

Only when you save.

#

So if youre editor/ide is set to save after each change, then yeah. it would reload.

humble lance
#

hm. so I would need to turn off autosave in vscode then for this to work effectivly

proud ingot
agile coral
gaunt wolf
#

Because it's not? I already have the console open since I"m in vscode making changes. It's not that inconvenient to save, then restart the bot.

#

Making changes, saving, then switching back to discord to run a command to restart the bot is just extra steps.

agile coral
#

an amateur case

gaunt wolf
#

reload=True is also a thing

#

Save and it will auto reload

agile coral
#

there are many ways , starting from restarting all cogs

gaunt wolf
#

👍

agile coral
#

restart=True + bot.close() the best to my mind, if you want fully restart it

#

Or just reload cogs, if not fully

bitter oxide
#

I'm like 99.99% certain restart is not a kwarg to bot, and reload=true won't really matter much when restarting

humble lance
bitter oxide
#

for all intents and purposes reloading should be enough, though

#

the only situation where reloading isn't enough is when you need to reload external files (as in stuff other than extensions), at which point simply closing the bot and restarting it won't help either

#

you'd need to have an external service running that automatically restarts your bot process when you stop the process