From 6b006129aa6fec35e893605b787b5d8afb6ade6f Mon Sep 17 00:00:00 2001 From: Jerrie-Aries <70805800+Jerrie-Aries@users.noreply.github.com> Date: Thu, 29 Apr 2021 07:21:08 +0800 Subject: [PATCH 1/2] Update database after resetting/purging all plugins. --- cogs/plugins.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/plugins.py b/cogs/plugins.py index 94a3f425c0..bc664aef44 100644 --- a/cogs/plugins.py +++ b/cogs/plugins.py @@ -539,6 +539,7 @@ async def plugins_reset(self, ctx): except Exception: logger.error("Failed to unload plugin: %s.", ext) self.bot.config["plugins"].clear() + await self.bot.config.update() cache_path = Path(__file__).absolute().parent.parent / "temp" / "plugins-cache" if cache_path.exists(): From fbb45e37829c2f17d81e5036794d197d14d30992 Mon Sep 17 00:00:00 2001 From: Jerrie-Aries <70805800+Jerrie-Aries@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:40:17 +0800 Subject: [PATCH 2/2] `plugin reset`, remove unloaded plugins from `self.loaded_plugins` --- cogs/plugins.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cogs/plugins.py b/cogs/plugins.py index bc664aef44..a01f4bc61c 100644 --- a/cogs/plugins.py +++ b/cogs/plugins.py @@ -538,6 +538,13 @@ async def plugins_reset(self, ctx): self.bot.unload_extension(ext) except Exception: logger.error("Failed to unload plugin: %s.", ext) + else: + if not self.loaded_plugins: + continue + plugin = next((p for p in self.loaded_plugins if p.ext_string == ext), None) + if plugin: + self.loaded_plugins.remove(plugin) + self.bot.config["plugins"].clear() await self.bot.config.update()