Add support for cog aliases
This commit is contained in:
parent
a62c0ff0d1
commit
cd5026dae4
@ -86,6 +86,10 @@ class CogMeta(type):
|
|||||||
The cog description. By default, it is the cleaned docstring of the class.
|
The cog description. By default, it is the cleaned docstring of the class.
|
||||||
|
|
||||||
.. versionadded:: 1.6
|
.. versionadded:: 1.6
|
||||||
|
aliases: Union[List[:class:`str`], Tuple[:class:`str`]]
|
||||||
|
A list of cog aliases. By default this is an empty list
|
||||||
|
|
||||||
|
..versionadded:: 2.0
|
||||||
|
|
||||||
command_attrs: :class:`dict`
|
command_attrs: :class:`dict`
|
||||||
A list of attributes to apply to every command inside this cog. The dictionary
|
A list of attributes to apply to every command inside this cog. The dictionary
|
||||||
@ -113,6 +117,8 @@ class CogMeta(type):
|
|||||||
name, bases, attrs = args
|
name, bases, attrs = args
|
||||||
attrs['__cog_name__'] = kwargs.pop('name', name)
|
attrs['__cog_name__'] = kwargs.pop('name', name)
|
||||||
attrs['__cog_settings__'] = kwargs.pop('command_attrs', {})
|
attrs['__cog_settings__'] = kwargs.pop('command_attrs', {})
|
||||||
|
|
||||||
|
attrs["__cog_aliases__"] = kwargs.pop("aliases", ())
|
||||||
|
|
||||||
description = kwargs.pop('description', None)
|
description = kwargs.pop('description', None)
|
||||||
if description is None:
|
if description is None:
|
||||||
@ -245,6 +251,15 @@ class Cog(metaclass=CogMeta):
|
|||||||
@description.setter
|
@description.setter
|
||||||
def description(self, description: str) -> None:
|
def description(self, description: str) -> None:
|
||||||
self.__cog_description__ = description
|
self.__cog_description__ = description
|
||||||
|
|
||||||
|
@property
|
||||||
|
def aliases(self) -> List[str]:
|
||||||
|
"""Union[List[:class:`str`], Tuple[:class:`str`]]: Returns the cog aliases."""
|
||||||
|
return self.__cog_aliases__
|
||||||
|
|
||||||
|
@aliases.setter
|
||||||
|
def aliases(self, aliases: List[str]) -> None:
|
||||||
|
self.__cog_aliases__ = aliases
|
||||||
|
|
||||||
def walk_commands(self) -> Generator[Command, None, None]:
|
def walk_commands(self) -> Generator[Command, None, None]:
|
||||||
"""An iterator that recursively walks through this cog's commands and subcommands.
|
"""An iterator that recursively walks through this cog's commands and subcommands.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user