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.
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user