mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
Start/Stop speaking events on UDP packets (#3578)
* Start/Stop speaking using incomming UDP packets * Fix ESLint errors * Updates for styling consistency Co-Authored-By: Gryffon Bellish <owenbellish@gmail.com> * Minor improvements * Acutally use previousTimeout * Use BaseClient setTimeout and refresh() * Update README to match node version for refresh() * Update comment to match startSpeaking * Correctly report Priority bit * Fix ESlint errors
This commit is contained in:
@@ -422,7 +422,7 @@ class VoiceConnection extends EventEmitter {
|
||||
udp.on('error', err => this.emit('error', err));
|
||||
ws.on('ready', this.onReady.bind(this));
|
||||
ws.on('sessionDescription', this.onSessionDescription.bind(this));
|
||||
ws.on('speaking', this.onSpeaking.bind(this));
|
||||
ws.on('startSpeaking', this.onStartSpeaking.bind(this));
|
||||
|
||||
this.sockets.ws.connect();
|
||||
}
|
||||
@@ -465,16 +465,19 @@ class VoiceConnection extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
onStartSpeaking({ user_id, ssrc, speaking }) {
|
||||
this.ssrcMap.set(+ssrc, { userID: user_id, speaking: speaking });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a speaking event is received.
|
||||
* @param {Object} data The received data
|
||||
* @private
|
||||
*/
|
||||
onSpeaking({ user_id, ssrc, speaking }) {
|
||||
onSpeaking({ user_id, speaking }) {
|
||||
speaking = new Speaking(speaking).freeze();
|
||||
const guild = this.channel.guild;
|
||||
const user = this.client.users.get(user_id);
|
||||
this.ssrcMap.set(+ssrc, user_id);
|
||||
const old = this._speaking.get(user_id);
|
||||
this._speaking.set(user_id, speaking);
|
||||
/**
|
||||
@@ -504,7 +507,7 @@ class VoiceConnection extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
play() {} // eslint-disable-line no-empty-function
|
||||
play() { } // eslint-disable-line no-empty-function
|
||||
}
|
||||
|
||||
PlayInterface.applyToClass(VoiceConnection);
|
||||
|
||||
Reference in New Issue
Block a user