mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
[V3 core.commands] decorator inheritence fix (#1786)
* decorator inheritence * black format
This commit is contained in:
parent
a0a2976e0a
commit
40feeff442
@ -48,6 +48,32 @@ class Command(commands.Command):
|
|||||||
# We don't want our help property to be overwritten, namely by super()
|
# We don't want our help property to be overwritten, namely by super()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def command(self, cls=None, *args, **kwargs):
|
||||||
|
"""A shortcut decorator that invokes :func:`.command` and adds it to
|
||||||
|
the internal command list via :meth:`~.GroupMixin.add_command`.
|
||||||
|
"""
|
||||||
|
cls = cls or self.__class__
|
||||||
|
|
||||||
|
def decorator(func):
|
||||||
|
result = command(*args, **kwargs)(func)
|
||||||
|
self.add_command(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
def group(self, cls=None, *args, **kwargs):
|
||||||
|
"""A shortcut decorator that invokes :func:`.group` and adds it to
|
||||||
|
the internal command list via :meth:`~.GroupMixin.add_command`.
|
||||||
|
"""
|
||||||
|
cls = None or Group
|
||||||
|
|
||||||
|
def decorator(func):
|
||||||
|
result = group(*args, **kwargs)(func)
|
||||||
|
self.add_command(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
class Group(Command, commands.Group):
|
class Group(Command, commands.Group):
|
||||||
"""Group command class for Red.
|
"""Group command class for Red.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user