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?
#bot restart command - discussion
1 messages · Page 1 of 1 (latest)
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.
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.
You could also just set reload=True in the bot constructor and it would reload any cogs that detect changes.
didn't know that was a thing. What would be an example of that?
But, the reality of a command vs ctrl+c, up, enter is not really that inconvenient
like bot = commands.Bot(cp=cp, intents=intents, reload=True)?
commands.Bot(..., reload=True)
But this only seems to work when cogs are loaded properly via bot.load_extension
that sounds like a neat thing, but like would it try and reload every single time I type a new character?
Only when you save.
So if youre editor/ide is set to save after each change, then yeah. it would reload.
hm. so I would need to turn off autosave in vscode then for this to work effectivly
HI use bot.close() to resart it put it into your commands
this is very convenient for development, you can not turn off the bot and run it again through the terminal, but just use a command that will do it faster, why not
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.
using the discord command, it works faster, you can use bot.reload_extension() for a specific module, to reload it with changes
an amateur case
there are many ways , starting from restarting all cogs
👍
restart=True + bot.close() the best to my mind, if you want fully restart it
Or just reload cogs, if not fully
I'm like 99.99% certain restart is not a kwarg to bot, and reload=true won't really matter much when restarting
reloading the cogs is what I had before, and it was just creating new instances of the bot instead of using the same instance
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