aboutsummaryrefslogtreecommitdiff
path: root/discord/server.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-10-15 01:02:15 -0400
committerRapptz <[email protected]>2015-10-15 01:37:55 -0400
commitab2512785b16d76a78f33e61a60ce90a2b225233 (patch)
treee18c594f06cea4d8eddca171da967944133e1306 /discord/server.py
parentHandle GUILD_ROLE_UPDATE websocket events. (diff)
downloaddiscord.py-ab2512785b16d76a78f33e61a60ce90a2b225233.tar.xz
discord.py-ab2512785b16d76a78f33e61a60ce90a2b225233.zip
Handle VOICE_STATE_UPDATE websocket events.
This adds a lot of new attributes into the Member class such as giving a voice_channel that the user is currently connected to. Initially there was a plan to have a voice_members attribute in the Channel class but this proved to be difficult when it came to actually removing users from the voice channel as the response would return channel_id as null. Fixes #16.
Diffstat (limited to 'discord/server.py')
-rw-r--r--discord/server.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/discord/server.py b/discord/server.py
index 51e5670b..8ddc9f0f 100644
--- a/discord/server.py
+++ b/discord/server.py
@@ -88,10 +88,23 @@ class Member(User):
.. attribute:: deaf
- Specifies if the member is currently deafened by the user.
+ A boolean that specifies if the member is currently deafened by the server.
.. attribute:: mute
- Specifies if the member is currently muted by the user.
+ A boolean that specifies if the member is currently muted by the server.
+ .. attribute:: self_mute
+
+ A boolean that specifies if the member is currently muted by their own accord.
+ .. attribute:: self_deaf
+
+ A boolean that specifies if the member is currently deafened by their own accord.
+ .. attribute:: is_afk
+
+ A boolean that specifies if the member is currently in the AFK channel in the server.
+ .. attribute:: voice_channel
+
+ A voice :class:`Channel` that the member is currently connected to. None if the member
+ is not currently in a voice channel.
.. attribute:: roles
An array of :class:`Role` that the member belongs to.
@@ -119,6 +132,15 @@ class Member(User):
self.status = 'offline'
self.game_id = kwargs.get('game_id', None)
self.server = kwargs.get('server', None)
+ self.update_voice_state(mute=mute, deaf=deaf)
+
+ def update_voice_state(self, **kwargs):
+ self.self_mute = kwargs.get('self_mute', False)
+ self.self_deaf = kwargs.get('self_deaf', False)
+ self.is_afk = kwargs.get('suppress', False)
+ self.mute = kwargs.get('mute', False)
+ self.deaf = kwargs.get('deaf', False)
+ self.voice_channel = kwargs.get('voice_channel')
class Server(object):
"""Represents a Discord server.