Browse Source

[commands] Return removed cog in Bot.remove_cog

The method now returns the removed cog, if it exists.
pull/7373/head
thetimtoy 4 years ago
committed by GitHub
parent
commit
c4ee9dcafa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      discord/ext/commands/bot.py

9
discord/ext/commands/bot.py

@ -548,7 +548,7 @@ class BotBase(GroupMixin):
return self.__cogs.get(name) return self.__cogs.get(name)
def remove_cog(self, 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 All registered commands and event listeners that the
cog has registered will be removed as well. cog has registered will be removed as well.
@ -559,6 +559,11 @@ class BotBase(GroupMixin):
----------- -----------
name: :class:`str` name: :class:`str`
The name of the cog to remove. 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) cog = self.__cogs.pop(name, None)
@ -570,6 +575,8 @@ class BotBase(GroupMixin):
help_command.cog = None help_command.cog = None
cog._eject(self) cog._eject(self)
return cog
@property @property
def cogs(self): def cogs(self):
"""Mapping[:class:`str`, :class:`Cog`]: A read-only mapping of cog name to cog.""" """Mapping[:class:`str`, :class:`Cog`]: A read-only mapping of cog name to cog."""

Loading…
Cancel
Save