[commands] Add check_any check to OR together various checks

This commit is contained in:
Rapptz
2020-01-06 22:03:27 -05:00
parent 51546dbdb6
commit ae3dac0d59
3 changed files with 93 additions and 0 deletions

View File

@ -34,6 +34,7 @@ __all__ = (
'PrivateMessageOnly',
'NoPrivateMessage',
'CheckFailure',
'CheckAnyFailure',
'CommandNotFound',
'DisabledCommand',
'CommandInvokeError',
@ -153,6 +154,26 @@ class CheckFailure(CommandError):
"""
pass
class CheckAnyFailure(CheckFailure):
"""Exception raised when all predicates in :func:`check_any` fail.
This inherits from :exc:`CheckFailure`.
.. versionadded:: 1.3
Attributes
------------
errors: List[:class:`CheckFailure`]
A list of errors that were caught during execution.
checks: List[Callable[[:class:`Context`], :class:`bool`]]
A list of check predicates that failed.
"""
def __init__(self, checks, errors):
self.checks = checks
self.errors = errors
super().__init__('You do not have permission to run this command.')
class PrivateMessageOnly(CheckFailure):
"""Exception raised when an operation does not work outside of private
message contexts.