voice: fix receiver null on immediate voiceStateUpdate

This commit is contained in:
Amish Shah
2018-11-15 21:38:02 +00:00
parent 3418b5a1a2
commit 2d68e837e5
3 changed files with 3 additions and 3 deletions

View File

@@ -113,7 +113,7 @@ class VoiceConnection extends EventEmitter {
* The voice receiver of this connection
* @type {VoiceReceiver}
*/
this.receiver = null;
this.receiver = new VoiceReceiver(this);
this.authenticate();
}
@@ -418,7 +418,6 @@ class VoiceConnection extends EventEmitter {
Object.assign(this.authentication, data);
this.status = VoiceStatus.CONNECTED;
clearTimeout(this.connectTimeout);
this.receiver = new VoiceReceiver(this);
/**
* Emitted once the connection is ready, when a promise to join a voice channel resolves,
* the connection will already be ready.

View File

@@ -108,6 +108,8 @@ class VoiceConnectionUDPClient extends EventEmitter {
},
},
});
socket.on('message', buffer => this.voiceConnection.receiver.packets.push(buffer));
});
const blankMessage = Buffer.alloc(70);

View File

@@ -21,7 +21,6 @@ class VoiceReceiver extends EventEmitter {
* @param {Error|string} error The error or message to debug
*/
this.packets.on('error', err => this.emit('debug', err));
this.connection.sockets.udp.socket.on('message', buffer => this.packets.push(buffer));
}
/**