aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-02-09 10:11:00 +0000
committerGravatar Gareth Coles <[email protected]>2018-02-09 10:11:00 +0000
commit449fc3774a45108f1bd0860fde0ef0d2764c0a8b (patch)
tree0d6d0196d5f2bfdaaa3235d0f721102600413cf8
parentHide bot command group in favour of function-like command (diff)
Role checks should return False in a DM
-rw-r--r--bot/decorators.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/bot/decorators.py b/bot/decorators.py
index 16d6b72fd..d76812341 100644
--- a/bot/decorators.py
+++ b/bot/decorators.py
@@ -5,6 +5,9 @@ from discord.ext.commands import Context
def with_role(*role_ids: int):
async def predicate(ctx: Context):
+ if not ctx.guild: # Return False in a DM
+ return False
+
for role in ctx.author.roles:
if role.id in role_ids:
return True
@@ -14,6 +17,9 @@ def with_role(*role_ids: int):
def without_role(*role_ids: int):
async def predicate(ctx: Context):
+ if not ctx.guild: # Return False in a DM
+ return False
+
author_roles = [role.id for role in ctx.author.roles]
return all(role not in author_roles for role in role_ids)
return commands.check(predicate)