Example #1
0
    def wrapper(command: Command) -> Command:
        # NOTE: this could be changed if a subclass of Command were to be used
        if not isinstance(command, Command):
            raise TypeError(
                'Decorator `cooldown_with_role_bypass` must be applied after the command decorator. '
                'This means it has to be above the command decorator in the code.'
            )

        command._before_invoke = predicate

        return command
Example #2
0
    def wrapper(command: Command) -> Command:
        # NOTE: this could be changed if a subclass of Command were to be used. I didn't see the need for it
        # so I just made it raise an error when the decorator is applied before the actual command object exists.
        #
        # if the `before_invoke` detail is ever a problem then I can quickly just swap over.
        if not isinstance(command, Command):
            raise TypeError('Decorator `cooldown_with_role_bypass` must be applied after the command decorator. '
                            'This means it has to be above the command decorator in the code.')

        command._before_invoke = predicate

        return command