mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Add VoiceConnection.disconnect([reason]);
This commit is contained in:
@@ -32,6 +32,19 @@ class VoiceConnectionUDPClient extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
_shutdown() {
|
||||
if (this.udpSocket) {
|
||||
try {
|
||||
this.udpSocket.close();
|
||||
} catch (err) {
|
||||
if (err.message !== 'Not running') {
|
||||
this.emit('error', err);
|
||||
}
|
||||
}
|
||||
this.udpSocket = null;
|
||||
}
|
||||
}
|
||||
|
||||
connectUDP(address) {
|
||||
this.udpIP = address;
|
||||
this.udpSocket = udp.createSocket('udp4');
|
||||
@@ -64,6 +77,10 @@ class VoiceConnectionUDPClient extends EventEmitter {
|
||||
this.emit('error', { error, message });
|
||||
});
|
||||
|
||||
this.udpSocket.on('close', error => {
|
||||
this.emit('close', error);
|
||||
});
|
||||
|
||||
const blankMessage = new Buffer(70);
|
||||
blankMessage.writeUIntBE(this.data.ssrc, 0, 4);
|
||||
this.send(blankMessage);
|
||||
|
||||
Reference in New Issue
Block a user