Added !unload all

Unloads all cogs at once
This commit is contained in:
Twentysix 2016-05-22 23:00:47 +02:00
parent 11dddc4e40
commit 3709d79f5b

View File

@ -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):