[commands] Added dm_only check

Raises PrivateMessageOnly on failure.
This commit is contained in:
Dante Dam
2019-04-09 09:23:02 -07:00
committed by Rapptz
parent 50dcdac5ca
commit aabbd5a446
2 changed files with 29 additions and 7 deletions

View File

@ -28,15 +28,15 @@ from discord.errors import DiscordException
__all__ = ['CommandError', 'MissingRequiredArgument', 'BadArgument',
'NoPrivateMessage', 'CheckFailure', 'CommandNotFound',
'DisabledCommand', 'CommandInvokeError', 'TooManyArguments',
'UserInputError', 'CommandOnCooldown', 'NotOwner',
'MissingPermissions', 'BotMissingPermissions', 'ConversionError',
'BadUnionArgument', 'ArgumentParsingError',
'PrivateMessageOnly', 'NoPrivateMessage', 'CheckFailure',
'CommandNotFound' ,'DisabledCommand', 'CommandInvokeError',
'TooManyArguments', 'UserInputError', 'CommandOnCooldown',
'NotOwner', 'MissingPermissions', 'BotMissingPermissions',
'ConversionError', 'BadUnionArgument', 'ArgumentParsingError',
'UnexpectedQuoteError', 'InvalidEndOfQuotedStringError',
'ExpectedClosingQuoteError', 'ExtensionError', 'ExtensionAlreadyLoaded',
'ExtensionNotLoaded', 'NoEntryPointError', 'ExtensionFailed',
'ExtensionNotFound' ]
'ExtensionNotFound']
class CommandError(DiscordException):
r"""The base exception type for all command related errors.
@ -118,6 +118,12 @@ class CheckFailure(CommandError):
"""Exception raised when the predicates in :attr:`.Command.checks` have failed."""
pass
class PrivateMessageOnly(CheckFailure):
"""Exception raised when an operation does not work outside of private
message contexts.
"""
pass
class NoPrivateMessage(CheckFailure):
"""Exception raised when an operation does not work in private message
contexts.