[commands] Add Command.cog_name to get the cog name it belongs to.

This commit is contained in:
Rapptz 2016-01-11 00:35:07 -05:00
parent 1e941925c2
commit c49efc5412

View File

@ -71,7 +71,8 @@ class Command:
help : str help : str
The long help text for the command. The long help text for the command.
brief : str brief : str
The short help text for the command. The short help text for the command. If this is not specified
then the first line of the long help text is used instead.
aliases : list aliases : list
The list of aliases the command can be invoked under. The list of aliases the command can be invoked under.
pass_context : bool pass_context : bool
@ -321,6 +322,11 @@ class Command:
self.on_error = coro self.on_error = coro
return coro return coro
@property
def cog_name(self):
"""The name of the cog this command belongs to. None otherwise."""
return type(self.instance).__name__ if self.instance is not None else None
class GroupMixin: class GroupMixin:
"""A mixin that implements common functionality for classes that behave """A mixin that implements common functionality for classes that behave
similar to :class:`Group` and are allowed to register commands. similar to :class:`Group` and are allowed to register commands.