fix(Voice*): internally disconnect and cleanup when forcibly disconnected (#3597)

This commit is contained in:
SpaceEEC
2020-01-05 18:10:20 +01:00
committed by GitHub
parent 1d6606293a
commit cbabc1663c
3 changed files with 19 additions and 4 deletions

View File

@@ -312,6 +312,15 @@ class VoiceConnection extends EventEmitter {
this.sendVoiceStateUpdate({
channel_id: null,
});
this._disconnect();
}
/**
* Internally disconnects (doesn't send disconnect packet).
* @private
*/
_disconnect() {
this.player.destroy();
this.cleanup();
this.status = Constants.VoiceStatus.DISCONNECTED;
@@ -334,6 +343,7 @@ class VoiceConnection extends EventEmitter {
ws.removeAllListeners('ready');
ws.removeAllListeners('sessionDescription');
ws.removeAllListeners('speaking');
ws.shutdown();
}
if (udp) udp.removeAllListeners('error');