attempt at cog aliases
This commit is contained in:
parent
0354036451
commit
f4bec507c1
@ -529,6 +529,9 @@ class BotBase(GroupMixin):
|
|||||||
|
|
||||||
cog = cog._inject(self)
|
cog = cog._inject(self)
|
||||||
self.__cogs[cog.__cog_name__] = cog
|
self.__cogs[cog.__cog_name__] = cog
|
||||||
|
if cog.aliases:
|
||||||
|
for alias in cog.aliases:
|
||||||
|
self.__cogs[alias] = cog
|
||||||
|
|
||||||
def get_cog(self, name):
|
def get_cog(self, name):
|
||||||
"""Gets the cog instance requested.
|
"""Gets the cog instance requested.
|
||||||
@ -567,6 +570,10 @@ class BotBase(GroupMixin):
|
|||||||
if cog is None:
|
if cog is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if cog.aliases:
|
||||||
|
for alias in cog.aliases:
|
||||||
|
self.__cogs.pop(alias)
|
||||||
|
|
||||||
help_command = self._help_command
|
help_command = self._help_command
|
||||||
if help_command and help_command.cog is cog:
|
if help_command and help_command.cog is cog:
|
||||||
help_command.cog = None
|
help_command.cog = None
|
||||||
|
@ -98,6 +98,11 @@ class CogMeta(type):
|
|||||||
attrs['__cog_name__'] = kwargs.pop('name', name)
|
attrs['__cog_name__'] = kwargs.pop('name', name)
|
||||||
attrs['__cog_settings__'] = command_attrs = kwargs.pop('command_attrs', {})
|
attrs['__cog_settings__'] = command_attrs = kwargs.pop('command_attrs', {})
|
||||||
|
|
||||||
|
aliases = kwargs.pop('aliases', [])
|
||||||
|
if not isinstance(aliases, list):
|
||||||
|
raise TypeError("Cog aliases must be a list, not a {0}".format(type(aliases)))
|
||||||
|
attrs['aliases'] = aliases
|
||||||
|
|
||||||
description = kwargs.pop('description', None)
|
description = kwargs.pop('description', None)
|
||||||
if description is None:
|
if description is None:
|
||||||
description = inspect.cleandoc(attrs.get('__doc__', ''))
|
description = inspect.cleandoc(attrs.get('__doc__', ''))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user