diff --git a/lib/Client/InternalClient.js b/lib/Client/InternalClient.js index 9356ad1c2..f7a7d25a7 100644 --- a/lib/Client/InternalClient.js +++ b/lib/Client/InternalClient.js @@ -76,27 +76,22 @@ var InternalClient = (function () { var session, token, server = channel.server, - endpoint, - fired = 0; + endpoint; var check = function check(m) { var data = JSON.parse(m); - if (data.t === "VOICE_STATE_UPDATE") { session = data.d.session_id; - fired++; } else if (data.t === "VOICE_SERVER_UPDATE") { token = data.d.token; endpoint = data.d.endpoint; - fired++; var chan = self.voiceConnection = new VoiceConnection(channel, self.client, session, token, server, endpoint); chan.on("ready", resolve); chan.on("error", reject); - } - if (fired >= 2) { + self.client.emit("debug", "removed temporary voice websocket listeners"); - self.websocket.removeListener('message', check); + self.websocket.removeListener("message", check); } }; diff --git a/lib/Voice/VoiceConnection.js b/lib/Voice/VoiceConnection.js index c63dc6dd0..a0daaeb83 100644 --- a/lib/Voice/VoiceConnection.js +++ b/lib/Voice/VoiceConnection.js @@ -192,7 +192,6 @@ var VoiceConnection = (function (_EventEmitter) { var self = this; return new Promise(function (resolve, reject) { _this.encoder.encodeFile(stream)["catch"](error).then(function (data) { - self.streamProc = data.proc; var intent = self.playRawStream(data.stream); resolve(intent); diff --git a/src/Client/InternalClient.js b/src/Client/InternalClient.js index 387787d72..ef2977e95 100644 --- a/src/Client/InternalClient.js +++ b/src/Client/InternalClient.js @@ -70,29 +70,24 @@ class InternalClient { self.leaveVoiceChannel().then(next); function next(){ - var session, token, server = channel.server, endpoint, fired = 0; + var session, token, server = channel.server, endpoint; var check = (m) => { var data = JSON.parse(m); - if(data.t === "VOICE_STATE_UPDATE"){ session = data.d.session_id; - fired++; }else if(data.t === "VOICE_SERVER_UPDATE"){ token = data.d.token; endpoint = data.d.endpoint; - fired++; var chan = self.voiceConnection = new VoiceConnection(channel, self.client, session, token, server, endpoint); chan.on("ready", resolve); chan.on("error", reject); - } - if(fired >= 2){ self.client.emit("debug", "removed temporary voice websocket listeners"); - self.websocket.removeListener('message', check); + self.websocket.removeListener("message", check); + } - }; self.websocket.on("message", check); diff --git a/src/Voice/VoiceConnection.js b/src/Voice/VoiceConnection.js index e2ca9f1ab..74ffad002 100644 --- a/src/Voice/VoiceConnection.js +++ b/src/Voice/VoiceConnection.js @@ -190,7 +190,6 @@ class VoiceConnection extends EventEmitter { .encodeFile(stream) .catch(error) .then(data => { - self.streamProc = data.proc; var intent = self.playRawStream(data.stream); resolve(intent); diff --git a/test/bot.1.js b/test/bot.1.js index 74530b68d..e597d6edc 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -24,6 +24,7 @@ client.on("message", m => { rest.splice(0, 1); rest = rest.join(" "); if(client.internal.voiceConnection){ + client.reply(m, "ok, I'll play that for you"); var connection = client.internal.voiceConnection; connection.playFile("C:/users/amish/desktop/"+rest); }