aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael H <[email protected]>2018-12-02 17:55:00 -0500
committerRapptz <[email protected]>2018-12-14 18:59:46 -0500
commitf45aef7c2eb4ba41370ec77d1a7871cdf7ee49b1 (patch)
treecb7bcd184a8487ecb882e99d83e05933253c1031
parentAdd override to `close()` method to the websocket subclass. (diff)
downloaddiscord.py-f45aef7c2eb4ba41370ec77d1a7871cdf7ee49b1.tar.xz
discord.py-f45aef7c2eb4ba41370ec77d1a7871cdf7ee49b1.zip
Handle implicit perms in discord.VoiceChannel.permissions_for
This adds some implicit permission handling for `discord.VoiceChannel.permissions_for` This is not documented behavior in discord's developer documentation, but it can easily be verified as correct.
-rw-r--r--discord/channel.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 7cb007a3..b2086933 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -460,6 +460,19 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
if member is not None:
ret.append(member)
return ret
+
+ def permissions_for(self, member):
+ base = super().permissions_for(member)
+
+ # voice channels cannot be edited by people who can't connect to them
+ # It also implicitly denies all other voice perms
+ if not base.connect:
+ denied = Permissions.voice()
+ denied.update(manage_channels=True, manage_roles=True)
+ base.value &= ~denied.value
+ return base
+
+ permissions_for.__doc__ = discord.abc.GuildChannel.permissions_for.__doc__
async def edit(self, *, reason=None, **options):
"""|coro|