Handle incomplete websocket message (#413)

Sometimes the VOICE_SERVER_UPDATE packet will contain a valid guild_id
but no token/endpoint.
This commit is contained in:
Programmix
2016-06-06 19:27:53 -07:00
committed by abal
parent e59dd9b12a
commit 02f39e00bf
2 changed files with 3 additions and 1 deletions

View File

@@ -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);

View File

@@ -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
);