diff --git a/cogs/owner.py b/cogs/owner.py index 4c3b101e9..2b5eedeaf 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -75,7 +75,7 @@ class Owner: await self.disable_commands() await self.bot.say("Module enabled.") - @commands.command() + @commands.group(invoke_without_command=True) @checks.is_owner() async def unload(self, *, module: str): """Unloads a module @@ -102,6 +102,29 @@ class Owner: else: await self.bot.say("Module disabled.") + @unload.command(name="all") + @checks.is_owner() + async def unload_all(self): + """Unloads all modules""" + cogs = self._list_cogs() + still_loaded = [] + for cog in cogs: + set_cog(cog, False) + try: + self._unload_cog(cog) + except OwnerUnloadWithoutReloadError: + pass + except CogUnloadError as e: + log.exception(e) + traceback.print_exc() + still_loaded.append(cog) + if still_loaded: + still_loaded = ", ".join(still_loaded) + await self.bot.say("I was unable to unload some cogs: " + "{}".format(still_loaded)) + else: + await self.bot.say("All cogs are now unloaded.") + @checks.is_owner() @commands.command(name="reload") async def _reload(self, module):