aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-06-28 20:30:31 -0400
committerRapptz <[email protected]>2016-06-28 20:34:03 -0400
commit0eccd857116ac5ba22902bb18d35ec72c7e5f863 (patch)
tree1830d76a760637bc50130632e69864e615b15190
parentAdd Server.mfa_level to query a server's 2FA requirement. (diff)
downloaddiscord.py-0eccd857116ac5ba22902bb18d35ec72c7e5f863.tar.xz
discord.py-0eccd857116ac5ba22902bb18d35ec72c7e5f863.zip
Add implicit cases to permission resolution in Channel.permissions_for
-rw-r--r--discord/channel.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 8968b42d..1dc82025 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -255,9 +255,28 @@ class Channel(Hashable):
if overwrite.type == 'member' and overwrite.id == member.id:
base.handle_overwrite(allow=overwrite.allow, deny=overwrite.deny)
+ # default channels can always be read
if self.is_default:
base.read_messages = True
+ # if you can't send a message in a channel then you can't have certain
+ # permissions as well
+ if not base.send_messages:
+ base.send_tts_messages = False
+ base.mention_everyone = False
+ base.embed_links = False
+ base.attach_files = False
+
+ # if you can't read a channel then you have no permissions there
+ if not base.read_messages:
+ denied = Permissions.all_channel()
+ base.value &= ~denied.value
+
+ # text channels do not have voice related permissions
+ if self.type is ChannelType.text:
+ denied = Permissions.voice()
+ base.value &= ~denied.value
+
return base
class PrivateChannel(Hashable):