diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index e89eaf3d6..fd2eb864a 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -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; }