diff options
| -rw-r--r-- | bot/decorators.py | 6 |
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) |