Fixes disconnecting VoiceConnections before connected (#1227)

This commit is contained in:
Programmix
2017-02-25 15:17:39 -08:00
committed by Amish Shah
parent f3a7f59824
commit 275c9953a0

View File

@@ -311,11 +311,18 @@ class VoiceConnection extends EventEmitter {
*/
cleanup() {
const { ws, udp } = this.sockets;
ws.removeAllListeners('error');
udp.removeAllListeners('error');
ws.removeAllListeners('ready');
ws.removeAllListeners('sessionDescription');
ws.removeAllListeners('speaking');
if (ws) {
ws.removeAllListeners('error');
ws.removeAllListeners('ready');
ws.removeAllListeners('sessionDescription');
ws.removeAllListeners('speaking');
}
if (udp) {
udp.removeAllListeners('error');
}
this.sockets.ws = null;
this.sockets.udp = null;
}