Add workaround to allow furiz restart bot
This commit is contained in:
1 file changed
+21
@@ -102,6 +102,27 @@ class BotManagement(commands.Cog, SingletonBase):
|
||||
except asyncio.exceptions.InvalidStateError:
|
||||
return task.exception()
|
||||
|
||||
@commands.command('shutdown')
|
||||
async def shutdown(self, ctx: Context) -> None:
|
||||
"""Shutdown bot with hope docker daemon will restart it, `@a31` and `@furiz__` has rights for it"""
|
||||
if ctx.author.id in (420130693696323585, # @a31
|
||||
444819880781545472): # @furiz__
|
||||
|
||||
log_msg = f"Got shutdown command by {ctx.author}"
|
||||
logger.info(log_msg)
|
||||
await ctx.reply('Shutting down')
|
||||
|
||||
try:
|
||||
await (await self.bot.fetch_user(420130693696323585)).send(log_msg)
|
||||
|
||||
except Exception as e:
|
||||
logger.opt(exception=e).warning(f'Failed to send shutdown message',)
|
||||
|
||||
self.bot.loop.create_task(self.bot.close())
|
||||
|
||||
else:
|
||||
await ctx.reply('No rights for you')
|
||||
|
||||
|
||||
async def setup(bot: commands.Bot):
|
||||
await bot.add_cog(BotManagement(bot))
|
||||
|
||||
Reference in new issue
Block a user