diff options
| author | Rapptz <[email protected]> | 2019-04-20 17:28:44 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-04-20 17:28:44 -0400 |
| commit | 5a7b5cd14ba87de38e8ef3701d3ed41b72fdaed6 (patch) | |
| tree | 8144ff3caceccde6b0e3b940e1c4a2dcb5989190 | |
| parent | [commands] DM channels are NSFW in commands.is_nsfw check. (diff) | |
| download | discord.py-5a7b5cd14ba87de38e8ef3701d3ed41b72fdaed6.tar.xz discord.py-5a7b5cd14ba87de38e8ef3701d3ed41b72fdaed6.zip | |
[commands] Allow passing of a message to NoPrivateMessage again.
Prevents an accidental breaking change.
| -rw-r--r-- | discord/ext/commands/core.py | 2 | ||||
| -rw-r--r-- | discord/ext/commands/errors.py | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index de36fe77..551ccfd1 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -1525,7 +1525,7 @@ def dm_only(): def predicate(ctx): if ctx.guild is not None: - raise PrivateMessageOnly('This command can only be used in private messages.') + raise PrivateMessageOnly() return True return check(predicate) diff --git a/discord/ext/commands/errors.py b/discord/ext/commands/errors.py index e41f36bd..85a45297 100644 --- a/discord/ext/commands/errors.py +++ b/discord/ext/commands/errors.py @@ -159,7 +159,8 @@ class PrivateMessageOnly(CheckFailure): This inherits from :exc:`CheckFailure` """ - pass + def __init__(self, message=None): + super().__init__(message or 'This command can only be used in private messages.') class NoPrivateMessage(CheckFailure): """Exception raised when an operation does not work in private message @@ -168,8 +169,8 @@ class NoPrivateMessage(CheckFailure): This inherits from :exc:`CheckFailure` """ - def __init__(self): - super().__init__('This command cannot be used in private messages.') + def __init__(self, message=None): + super().__init__(message or 'This command cannot be used in private messages.') class NotOwner(CheckFailure): """Exception raised when the message author is not the owner of the bot. |