From 02f39e00bfbd5c0d6d3df506f2fe887aa62d5704 Mon Sep 17 00:00:00 2001 From: Programmix Date: Mon, 6 Jun 2016 19:27:53 -0700 Subject: [PATCH] Handle incomplete websocket message (#413) Sometimes the VOICE_SERVER_UPDATE packet will contain a valid guild_id but no token/endpoint. --- lib/Client/InternalClient.js | 1 + src/Client/InternalClient.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index ecc2863ee..fd9af1619 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -375,6 +375,7 @@ var InternalClient = (function () { if (data.d.guild_id !== server.id) return; // ensure it is the right server token = data.d.token; endpoint = data.d.endpoint; + if (!token || !endpoint) return; var chan = new _VoiceVoiceConnection2["default"](channel, _this5.client, session, token, server, endpoint); _this5.voiceConnections.add(chan); diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 7ed897ba8..07d7edc0c 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -292,9 +292,10 @@ export default class InternalClient { var check = data => { if (data.t === "VOICE_SERVER_UPDATE") { - if (data.d.guild_id !== server.id) return // ensure it is the right server + if (data.d.guild_id !== server.id) return; // ensure it is the right server token = data.d.token; endpoint = data.d.endpoint; + if (!token || !endpoint) return; var chan = new VoiceConnection( channel, this.client, session, token, server, endpoint );