Added voice disconnect

This commit is contained in:
Amish Shah
2016-10-25 14:18:20 +01:00
parent b0921ae0ef
commit 91ba59c43d
8 changed files with 56 additions and 11 deletions

View File

@@ -49,6 +49,17 @@ class VoiceConnectionUDPClient extends EventEmitter {
* @type {?string}
*/
this.localPort = null;
this.voiceConnection.on('closing', this.shutdown.bind(this));
}
shutdown() {
if (this.socket) {
try {
this.socket.close();
} catch (e) {
return;
}
this.socket = null;
}
}
/**
* The port of the discord voice server
@@ -57,7 +68,6 @@ class VoiceConnectionUDPClient extends EventEmitter {
get discordPort() {
return this.voiceConnection.authentication.port;
}
/**
* Tries to resolve the voice server endpoint to an address
* @returns {Promise<string>}