diff options
| author | 2020-12-02 18:43:22 +0200 | |
|---|---|---|
| committer | 2020-12-02 18:43:22 +0200 | |
| commit | 690ccd246e12d18a8c804b0802772f4a66a96bb8 (patch) | |
| tree | ffb8e07ed96dae0f6d1caa9a279d9a8fe5bd5a45 | |
| parent | Add failure message when applying infraction fails because user left (diff) | |
Fix removing extensions and cogs for bot shutdown
| -rw-r--r-- | bot/bot.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bot/bot.py b/bot/bot.py index cdb4e72a9..06b1bd6e0 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -175,9 +175,13 @@ class Bot(commands.Bot): async def close(self) -> None: """Close the Discord connection and the aiohttp session, connector, statsd client, and resolver.""" # Done before super().close() to allow tasks finish before the HTTP session closes. - with suppress(Exception): - [self.unload_extension(ext) for ext in tuple(self.extensions)] - [self.remove_cog(cog) for cog in tuple(self.cogs)] + for ext in list(self.extensions): + with suppress(Exception): + self.unload_extension(ext) + + for cog in list(self.cogs): + with suppress(Exception): + self.remove_cog(cog) # Wait until all tasks that have to be completed before bot is closing is done log.trace("Waiting for tasks before closing.") |