From 67d2d09fa3e989e798ab5a9ef0863ad4f34c1958 Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:24:12 +0300 Subject: [PATCH] Add workaround to allow furiz restart bot --- cogs/BotManagement.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cogs/BotManagement.py b/cogs/BotManagement.py index 60cbe5a..8d5cf34 100644 --- a/cogs/BotManagement.py +++ b/cogs/BotManagement.py @@ -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))