[V3 core.commands] decorator inheritence fix (#1786)

* decorator inheritence

* black format
This commit is contained in:
Michael H 2018-06-02 22:34:30 -04:00 committed by palmtree5
parent a0a2976e0a
commit 40feeff442

View File

@ -48,6 +48,32 @@ class Command(commands.Command):
# We don't want our help property to be overwritten, namely by super()
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):
"""Group command class for Red.