From bb716480b15e25059807b9596042d78195e9d5ad Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Mon, 9 Nov 2015 18:34:03 +0000 Subject: [PATCH] Fixed leaving voice channels --- lib/Voice/VoiceConnection.js | 10 ++++++++++ src/Voice/VoiceConnection.js | 12 ++++++++++++ test/bot.1.js | 3 +++ 3 files changed, 25 insertions(+) diff --git a/lib/Voice/VoiceConnection.js b/lib/Voice/VoiceConnection.js index 3219bab29..c069821b5 100644 --- a/lib/Voice/VoiceConnection.js +++ b/lib/Voice/VoiceConnection.js @@ -48,10 +48,20 @@ var VoiceConnection = (function (_EventEmitter) { } VoiceConnection.prototype.destroy = function destroy() { + console.log("you wanted to destroy _me_?!"); this.stopPlaying(); if (this.KAI) clearInterval(this.KAI); this.vWS.close(); this.udp.close(); + this.client.internal.sendWS({ + op: 4, + d: { + guild_id: null, + channel_id: null, + self_mute: true, + self_deaf: false + } + }); }; VoiceConnection.prototype.stopPlaying = function stopPlaying() { diff --git a/src/Voice/VoiceConnection.js b/src/Voice/VoiceConnection.js index d52dbacaf..009e07353 100644 --- a/src/Voice/VoiceConnection.js +++ b/src/Voice/VoiceConnection.js @@ -40,11 +40,23 @@ class VoiceConnection extends EventEmitter { } destroy() { + console.log("you wanted to destroy _me_?!"); this.stopPlaying(); if(this.KAI) clearInterval(this.KAI); this.vWS.close(); this.udp.close(); + this.client.internal.sendWS( + { + op : 4, + d : { + guild_id : null, + channel_id : null, + self_mute : true, + self_deaf : false + } + } + ); } stopPlaying() { diff --git a/test/bot.1.js b/test/bot.1.js index bd2f540e4..31194ceb1 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -20,6 +20,9 @@ client.on("message", m => { client.internal.voiceConnection.stopPlaying(); } return; + }if (m.content.startsWith("$$$ leave")) { + client.internal.leaveVoiceChannel(); + return; } if (m.content.startsWith("$$$")) { var chan;