diff options
| author | thetimtoy <[email protected]> | 2021-08-17 21:39:54 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-18 00:39:54 -0400 |
| commit | c4ee9dcafad98b5df83217b2c9fbfbe0cdd83cc2 (patch) | |
| tree | 5e5023ca1da388d2f2cd911543f1f6cbe8dc4e19 /discord/ext/commands/bot.py | |
| parent | Type-hint user.py (diff) | |
| download | discord.py-c4ee9dcafad98b5df83217b2c9fbfbe0cdd83cc2.tar.xz discord.py-c4ee9dcafad98b5df83217b2c9fbfbe0cdd83cc2.zip | |
[commands] Return removed cog in Bot.remove_cog
The method now returns the removed cog, if it exists.
Diffstat (limited to 'discord/ext/commands/bot.py')
| -rw-r--r-- | discord/ext/commands/bot.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index cba7d1e0..7c49bf96 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -548,7 +548,7 @@ class BotBase(GroupMixin): return self.__cogs.get(name) def remove_cog(self, name): - """Removes a cog from the bot. + """Removes a cog from the bot and returns it. All registered commands and event listeners that the cog has registered will be removed as well. @@ -559,6 +559,11 @@ class BotBase(GroupMixin): ----------- name: :class:`str` The name of the cog to remove. + + Returns + ------- + Optional[:class:`.Cog`] + The cog that was removed. ``None`` if not found. """ cog = self.__cogs.pop(name, None) @@ -570,6 +575,8 @@ class BotBase(GroupMixin): help_command.cog = None cog._eject(self) + return cog + @property def cogs(self): """Mapping[:class:`str`, :class:`Cog`]: A read-only mapping of cog name to cog.""" |