1
0
Fork 0
mirror of synced 2024-06-16 17:44:33 +12:00

Check both guild and channel permissions

This commit is contained in:
Phxntxm 2017-07-27 13:56:12 -05:00
parent c3e8e0fac6
commit 54967acfbd

View file

@ -165,9 +165,10 @@ def custom_perms(**perms):
return True return True
# Get the member permissions so that we can compare # Get the member permissions so that we can compare
member_perms = ctx.message.author.guild_permissions guild_perms = ctx.message.author.guild_permissions
channel_perms = ctx.message.author.permissions_in(ctx.message.channel)
# Currently the library doesn't handle administrator overrides..so lets do this manually # Currently the library doesn't handle administrator overrides..so lets do this manually
if member_perms.administrator: if guild_perms.administrator:
return True return True
# Next, set the default permissions if one is not used, based on what was passed # Next, set the default permissions if one is not used, based on what was passed
# This will be overriden later, if we have custom permissions # This will be overriden later, if we have custom permissions
@ -181,7 +182,7 @@ def custom_perms(**perms):
required_perm = discord.Permissions(required_perm_value) required_perm = discord.Permissions(required_perm_value)
# Now just check if the person running the command has these permissions # Now just check if the person running the command has these permissions
return member_perms >= required_perm return guild_perms >= required_perm or channel_perms >= required_perm
predicate.perms = perms predicate.perms = perms
return commands.check(predicate) return commands.check(predicate)