From 82c2e759bd946e284d1a79aa8c32d34fc8b7514f Mon Sep 17 00:00:00 2001 From: Alexander Terry Date: Thu, 7 Sep 2017 09:57:04 -0800 Subject: [PATCH] safty around reload cogs.utils --- cogs/exec.py | 11 +++++++++++ cogs/utils.py | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cogs/exec.py b/cogs/exec.py index 68e8f70..a7e8beb 100644 --- a/cogs/exec.py +++ b/cogs/exec.py @@ -185,6 +185,17 @@ async def shell(self, ctx, *, cmd): result = await run_subprocess(cmd) await ctx.send(f'```{result}```') + @commands.command() + @commands.is_owner() + async def reloadutils(self,ctx): + try: + self.bot.unload_extension("cogs.utils") + self.bot.load_extension("cogs.utils") + except Exception as e: + await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}') + else: + await ctx.send('**`SUCCESS`**') + def setup(bot): bot.add_cog(Exec(bot)) diff --git a/cogs/utils.py b/cogs/utils.py index ca48198..44c2bb4 100644 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -14,7 +14,9 @@ class Utils(Cog): async def cog_reload(self, ctx, *, cog: str): """Command which Reloads a Module. Remember to use dot path. e.g: cogs.owner""" - + if cog == "cogs.utils": + ctx.send("im sorry, i cant reload myself for safety reasons.") + return try: self.bot.unload_extension(cog) self.bot.load_extension(cog)