GuildMember#voice never undefined, improve documentation for VoiceState

This commit is contained in:
Amish Shah
2018-08-10 17:05:26 +01:00
parent 00ac62f975
commit e059581eee
2 changed files with 13 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ const Role = require('./Role');
const Permissions = require('../util/Permissions'); const Permissions = require('../util/Permissions');
const GuildMemberRoleStore = require('../stores/GuildMemberRoleStore'); const GuildMemberRoleStore = require('../stores/GuildMemberRoleStore');
const Base = require('./Base'); const Base = require('./Base');
const VoiceState = require('./VoiceState');
const { Presence } = require('./Presence'); const { Presence } = require('./Presence');
const { Error } = require('../errors'); const { Error } = require('../errors');
@@ -96,7 +97,7 @@ class GuildMember extends Base {
} }
get voice() { get voice() {
return this.guild.voiceStates.get(this.id); return this.guild.voiceStates.get(this.id) || new VoiceState(this.guild, { user_id: this.id });
} }
/** /**

View File

@@ -22,32 +22,32 @@ class VoiceState extends Base {
_patch(data) { _patch(data) {
/** /**
* Whether this member is deafened server-wide * Whether this member is deafened server-wide
* @type {boolean} * @type {?boolean}
*/ */
this.serverDeaf = data.deaf; this.serverDeaf = data.deaf;
/** /**
* Whether this member is muted server-wide * Whether this member is muted server-wide
* @type {boolean} * @type {?boolean}
*/ */
this.serverMute = data.mute; this.serverMute = data.mute;
/** /**
* Whether this member is self-deafened * Whether this member is self-deafened
* @type {boolean} * @type {?boolean}
*/ */
this.selfDeaf = data.self_deaf; this.selfDeaf = data.self_deaf;
/** /**
* Whether this member is self-muted * Whether this member is self-muted
* @type {boolean} * @type {?boolean}
*/ */
this.selfMute = data.self_mute; this.selfMute = data.self_mute;
/** /**
* The session ID of this member's connection * The session ID of this member's connection
* @type {String} * @type {?string}
*/ */
this.sessionID = data.session_id; this.sessionID = data.session_id;
/** /**
* The ID of the voice channel that this member is in * The ID of the voice channel that this member is in
* @type {Snowflake} * @type {?Snowflake}
*/ */
this.channelID = data.channel_id; this.channelID = data.channel_id;
return this; return this;
@@ -55,7 +55,7 @@ class VoiceState extends Base {
/** /**
* The member that this voice state belongs to * The member that this voice state belongs to
* @type {GuildMember} * @type {?GuildMember}
*/ */
get member() { get member() {
return this.guild.members.get(this.id); return this.guild.members.get(this.id);
@@ -63,7 +63,7 @@ class VoiceState extends Base {
/** /**
* The channel that the member is connected to * The channel that the member is connected to
* @type {VoiceChannel} * @type {?VoiceChannel}
*/ */
get channel() { get channel() {
return this.guild.channels.get(this.channelID); return this.guild.channels.get(this.channelID);
@@ -71,7 +71,7 @@ class VoiceState extends Base {
/** /**
* Whether this member is either self-deafened or server-deafened * Whether this member is either self-deafened or server-deafened
* @type {boolean} * @type {?boolean}
*/ */
get deaf() { get deaf() {
return this.serverDeaf || this.selfDeaf; return this.serverDeaf || this.selfDeaf;
@@ -79,7 +79,7 @@ class VoiceState extends Base {
/** /**
* Whether this member is either self-muted or server-muted * Whether this member is either self-muted or server-muted
* @type {boolean} * @type {?boolean}
*/ */
get mute() { get mute() {
return this.serverMute || this.selfMute; return this.serverMute || this.selfMute;
@@ -88,7 +88,7 @@ class VoiceState extends Base {
/** /**
* Whether this member is currently speaking. A boolean if the information is available (aka * Whether this member is currently speaking. A boolean if the information is available (aka
* the bot is connected to any voice channel in the guild), otherwise this is null * the bot is connected to any voice channel in the guild), otherwise this is null
* @type {boolean|null} * @type {?boolean}
*/ */
get speaking() { get speaking() {
return this.channel && this.channel.connection ? return this.channel && this.channel.connection ?