diff options
author | 2019-09-14 15:04:58 -0700 | |
---|---|---|
committer | 2019-09-14 16:07:56 -0700 | |
commit | 6a6590124217cd51ff17c17d2cec0dca9bea1090 (patch) | |
tree | e40ab6e90405606a80037c4413482167179b31c0 | |
parent | Ignore errors from cogs with their own error handlers (diff) |
Display no-DM error message originating from security cog's global check
The check will behave like Discord.py's guild_only check by raising the
NoPrivateMessage exception.
-rw-r--r-- | bot/cogs/security.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bot/cogs/security.py b/bot/cogs/security.py index f4a843fbf..9523766af 100644 --- a/bot/cogs/security.py +++ b/bot/cogs/security.py @@ -1,6 +1,6 @@ import logging -from discord.ext.commands import Bot, Context +from discord.ext.commands import Bot, Context, NoPrivateMessage log = logging.getLogger(__name__) @@ -19,7 +19,9 @@ class Security: return not ctx.author.bot def check_on_guild(self, ctx: Context): - return ctx.guild is not None + if ctx.guild is None: + raise NoPrivateMessage("This command cannot be used in private messages.") + return True def setup(bot): |