From 2d32e9e52acde1f98db9afb7df6fa3fb4622086d Mon Sep 17 00:00:00 2001 From: Anis B Date: Wed, 6 Dec 2017 03:05:26 +0100 Subject: [PATCH] Fix overwrites order in Channel.get_permissions (#66) * Fix overwrites order in get_permissions * [flake8] Remove whitespaces --- disco/types/channel.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/disco/types/channel.py b/disco/types/channel.py index 89f6716..2419bec 100644 --- a/disco/types/channel.py +++ b/disco/types/channel.py @@ -159,12 +159,18 @@ class Channel(SlottedModel, Permissible): member = self.guild.get_member(user) base = self.guild.get_permissions(member) - for ow in six.itervalues(self.overwrites): - if ow.id != user.id and ow.id not in member.roles: - continue - - base -= ow.deny - base += ow.allow + ow_everyone = self.overwrites.get(self.guild_id) + if ow_everyone: + base += ow_everyone.compiled + + for role_id in member.roles: + ow_role = self.overwrites.get(role_id) + if ow_role: + base += ow_role.compiled + + ow_member = self.overwrites.get(member.user.id) + if ow_member: + base += ow_member.compiled return base