From 3b1b26ffb1c9a75ac9c3f958d6e134ccddd6be07 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 18 Apr 2017 02:29:43 -0400 Subject: Re-implement voice sending. This is a complete redesign of the old voice code. A list of major changes is as follows: * The voice websocket will now automatically reconnect with exponential back-off just like the regular Client does. * Removal of the stream player concept. * Audio now gracefully pauses and resumes when a disconnect is found. * Introduce a discord.AudioSource concept to abstract streams * Flatten previous stream player functionality with the VoiceClient, e.g. player.stop() is now voice_client.stop() * With the above re-coupling this means you no longer have to store players anywhere. * The after function now requires a single parameter, the error, if any existed. This will typically be None. A lot of this design is experimental. --- discord/state.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'discord/state.py') diff --git a/discord/state.py b/discord/state.py index 8d0757dd..10f6d16e 100644 --- a/discord/state.py +++ b/discord/state.py @@ -688,6 +688,16 @@ class ConnectionState: if call is not None: call._update_voice_state(data) + def parse_voice_server_update(self, data): + try: + key_id = int(data['guild_id']) + except KeyError: + key_id = int(data['channel_id']) + + vc = self._get_voice_client(key_id) + if vc is not None and vc.is_connected(): + compat.create_task(vc._switch_regions()) + def parse_typing_start(self, data): channel = self.get_channel(int(data['channel_id'])) if channel is not None: -- cgit v1.2.3