mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
Added !unload all
Unloads all cogs at once
This commit is contained in:
parent
11dddc4e40
commit
3709d79f5b
@ -75,7 +75,7 @@ class Owner:
|
|||||||
await self.disable_commands()
|
await self.disable_commands()
|
||||||
await self.bot.say("Module enabled.")
|
await self.bot.say("Module enabled.")
|
||||||
|
|
||||||
@commands.command()
|
@commands.group(invoke_without_command=True)
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
async def unload(self, *, module: str):
|
async def unload(self, *, module: str):
|
||||||
"""Unloads a module
|
"""Unloads a module
|
||||||
@ -102,6 +102,29 @@ class Owner:
|
|||||||
else:
|
else:
|
||||||
await self.bot.say("Module disabled.")
|
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()
|
@checks.is_owner()
|
||||||
@commands.command(name="reload")
|
@commands.command(name="reload")
|
||||||
async def _reload(self, module):
|
async def _reload(self, module):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user