From ab2512785b16d76a78f33e61a60ce90a2b225233 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 15 Oct 2015 01:02:15 -0400 Subject: 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. --- discord/server.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'discord/server.py') 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. -- cgit v1.2.3