aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-07-31 18:00:36 +0300
committerGravatar GitHub <[email protected]>2020-07-31 18:00:36 +0300
commit65c4312515de65a59b7553b0581c31d0d9fa098b (patch)
treec59b8f604482e6e93ec1cc69b58c6640d9f64107
parentImprove extension + cogs removing comment on `close` (diff)
Simplify bot shutdown cogs removing
Unloading extensions already remove all cogs that is inside it and this is enough good for this case, because bot still call dpy's internal function later to remove cogs not related with extensions (when exist).
-rw-r--r--bot/bot.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 7a8f9932c..5e05d1596 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -93,16 +93,10 @@ class Bot(commands.Bot):
super().clear()
def _remove_extensions(self) -> None:
- """Remove all extensions and Cog to close bot. Copyright (c) 2015-2020 Rapptz (discord.py, MIT License)."""
- for extension in tuple(self.extensions):
+ """Remove all extensions to trigger cog unloads."""
+ for ext in self.extensions.keys():
try:
- self.unload_extension(extension)
- except Exception:
- pass
-
- for cog in tuple(self.cogs):
- try:
- self.remove_cog(cog)
+ self.unload_extension(ext)
except Exception:
pass