Client now keeps a reference to the VoiceClient constructed.

This commit is contained in:
Rapptz
2015-12-09 21:32:33 -05:00
parent 5335f468d2
commit eda3c626db
2 changed files with 30 additions and 11 deletions

View File

@ -134,14 +134,16 @@ class VoiceClient:
The endpoint we are connecting to.
channel : :class:`Channel`
The voice channel connected to.
loop
The event loop that the voice client is running on.
"""
def __init__(self, user, connected, main_ws, session_id, channel, data, loop):
def __init__(self, user, main_ws, session_id, channel, data, loop):
self.user = user
self._connected = connected
self.main_ws = main_ws
self.channel = channel
self.session_id = session_id
self.loop = loop
self._connected = asyncio.Event(loop=self.loop)
self.token = data.get('token')
self.guild_id = data.get('guild_id')
self.endpoint = data.get('endpoint')
@ -296,6 +298,10 @@ class VoiceClient:
yield from self.main_ws.send(utils.to_json(payload))
def is_connected(self):
"""bool : Indicates if the voice client is connected to voice."""
return self._connected.is_set()
# audio related
def _get_voice_packet(self, data):