voice: rewrite GuildMember#speaking tracking (#2540)

This commit is contained in:
Amish Shah
2018-08-09 13:59:52 +01:00
parent f3d7f7c3bd
commit ee6c19ca7e
3 changed files with 37 additions and 32 deletions

View File

@@ -56,14 +56,19 @@ class GuildMember extends Base {
if (data) this._patch(data);
}
_patch(data) {
/**
* Whether this member is speaking and the client is in the same channel
* @type {boolean}
* @name GuildMember#speaking
*/
if (typeof this.speaking === 'undefined') this.speaking = false;
/**
* Whether this member is speaking. If the client isn't sure, then this will be undefined. Otherwise it will be
* true/false
* @type {?boolean}
* @name GuildMember#speaking
*/
get speaking() {
return this.voiceChannel && this.voiceChannel.connection ?
Boolean(this.voiceChannel.connection._speaking.get(this.id)) :
undefined;
}
_patch(data) {
/**
* The nickname of this member, if they have one
* @type {?string}