diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index 456e8d09..7029011b 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -255,6 +255,11 @@ class VoiceConnection extends EventEmitter { */ this.emit('failed', new Error(reason)); } else { + /** + * Emitted whenever the connection encounters an error. + * @event VoiceConnection#error + * @param {Error} error The encountered error + */ this.emit('error', new Error(reason)); } this.status = Constants.VoiceStatus.DISCONNECTED; @@ -367,20 +372,10 @@ class VoiceConnection extends EventEmitter { * @param {Object} data The received data * @private */ - onReady({ port, ssrc }) { + onReady({ port, ssrc, ip }) { this.authentication.port = port; this.authentication.ssrc = ssrc; - - const udp = this.sockets.udp; - /** - * Emitted whenever the connection encounters an error. - * @event VoiceConnection#error - * @param {Error} error The encountered error - */ - udp.findEndpointAddress() - .then(address => { - udp.createUDPSocket(address); - }, e => this.emit('error', e)); + this.sockets.udp.createUDPSocket(ip); } /** diff --git a/src/client/voice/VoiceUDPClient.js b/src/client/voice/VoiceUDPClient.js index 0e148b75..cf1e388f 100644 --- a/src/client/voice/VoiceUDPClient.js +++ b/src/client/voice/VoiceUDPClient.js @@ -1,5 +1,4 @@ const udp = require('dgram'); -const dns = require('dns'); const Constants = require('../../util/Constants'); const EventEmitter = require('events').EventEmitter; @@ -65,23 +64,6 @@ class VoiceConnectionUDPClient extends EventEmitter { return this.voiceConnection.authentication.port; } - /** - * Tries to resolve the voice server endpoint to an address. - * @returns {Promise} - */ - findEndpointAddress() { - return new Promise((resolve, reject) => { - dns.lookup(this.voiceConnection.authentication.endpoint, (error, address) => { - if (error) { - reject(error); - return; - } - this.discordAddress = address; - resolve(address); - }); - }); - } - /** * Send a packet to the UDP client. * @param {Object} packet The packet to send