Fixed leaving voice channels

This commit is contained in:
hydrabolt
2015-11-09 18:34:03 +00:00
parent 544f7da139
commit bb716480b1
3 changed files with 25 additions and 0 deletions

View File

@@ -48,10 +48,20 @@ var VoiceConnection = (function (_EventEmitter) {
} }
VoiceConnection.prototype.destroy = function destroy() { VoiceConnection.prototype.destroy = function destroy() {
console.log("you wanted to destroy _me_?!");
this.stopPlaying(); this.stopPlaying();
if (this.KAI) clearInterval(this.KAI); if (this.KAI) clearInterval(this.KAI);
this.vWS.close(); this.vWS.close();
this.udp.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() { VoiceConnection.prototype.stopPlaying = function stopPlaying() {

View File

@@ -40,11 +40,23 @@ class VoiceConnection extends EventEmitter {
} }
destroy() { destroy() {
console.log("you wanted to destroy _me_?!");
this.stopPlaying(); this.stopPlaying();
if(this.KAI) if(this.KAI)
clearInterval(this.KAI); clearInterval(this.KAI);
this.vWS.close(); this.vWS.close();
this.udp.close(); this.udp.close();
this.client.internal.sendWS(
{
op : 4,
d : {
guild_id : null,
channel_id : null,
self_mute : true,
self_deaf : false
}
}
);
} }
stopPlaying() { stopPlaying() {

View File

@@ -20,6 +20,9 @@ client.on("message", m => {
client.internal.voiceConnection.stopPlaying(); client.internal.voiceConnection.stopPlaying();
} }
return; return;
}if (m.content.startsWith("$$$ leave")) {
client.internal.leaveVoiceChannel();
return;
} }
if (m.content.startsWith("$$$")) { if (m.content.startsWith("$$$")) {
var chan; var chan;