diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 1061b9880..8f2a87b19 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -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.