refactor: improve the accuracy of docs/improve docs (#4845)

Co-authored-by: Noel <icrawltogo@gmail.com>
This commit is contained in:
Sugden
2020-10-17 14:53:02 +01:00
committed by GitHub
parent 4bbe716aa0
commit af670fc718
22 changed files with 185 additions and 166 deletions

View File

@@ -165,7 +165,7 @@ class VoiceConnection extends EventEmitter {
/** /**
* The voice state of this connection * The voice state of this connection
* @type {VoiceState} * @type {?VoiceState}
*/ */
get voice() { get voice() {
return this.channel.guild.voice; return this.channel.guild.voice;
@@ -203,8 +203,8 @@ class VoiceConnection extends EventEmitter {
* Set the token and endpoint required to connect to the voice servers. * Set the token and endpoint required to connect to the voice servers.
* @param {string} token The voice token * @param {string} token The voice token
* @param {string} endpoint The voice endpoint * @param {string} endpoint The voice endpoint
* @private
* @returns {void} * @returns {void}
* @private
*/ */
setTokenAndEndpoint(token, endpoint) { setTokenAndEndpoint(token, endpoint) {
this.emit('debug', `Token "${token}" and endpoint "${endpoint}"`); this.emit('debug', `Token "${token}" and endpoint "${endpoint}"`);

View File

@@ -56,7 +56,7 @@ class StreamDispatcher extends Writable {
* The broadcast controlling this dispatcher, if any * The broadcast controlling this dispatcher, if any
* @type {?VoiceBroadcast} * @type {?VoiceBroadcast}
*/ */
this.broadcast = this.streams.broadcast; this.broadcast = this.streams.broadcast || null;
this._pausedTime = 0; this._pausedTime = 0;
this._silentPausedTime = 0; this._silentPausedTime = 0;

View File

@@ -43,7 +43,7 @@ class WebSocketManager extends EventEmitter {
* The gateway this manager uses * The gateway this manager uses
* @type {?string} * @type {?string}
*/ */
this.gateway = undefined; this.gateway = null;
/** /**
* The amount of shards this manager handles * The amount of shards this manager handles
@@ -98,11 +98,11 @@ class WebSocketManager extends EventEmitter {
* The current session limit of the client * The current session limit of the client
* @private * @private
* @type {?Object} * @type {?Object}
* @prop {number} total Total number of identifies available * @property {number} total Total number of identifies available
* @prop {number} remaining Number of identifies remaining * @property {number} remaining Number of identifies remaining
* @prop {number} reset_after Number of milliseconds after which the limit resets * @property {number} reset_after Number of milliseconds after which the limit resets
*/ */
this.sessionStartLimit = undefined; this.sessionStartLimit = null;
} }
/** /**
@@ -212,7 +212,7 @@ class WebSocketManager extends EventEmitter {
if (UNRESUMABLE_CLOSE_CODES.includes(event.code)) { if (UNRESUMABLE_CLOSE_CODES.includes(event.code)) {
// These event codes cannot be resumed // These event codes cannot be resumed
shard.sessionID = undefined; shard.sessionID = null;
} }
/** /**

View File

@@ -56,10 +56,10 @@ class WebSocketShard extends EventEmitter {
/** /**
* The current session ID of the shard * The current session ID of the shard
* @type {string} * @type {?string}
* @private * @private
*/ */
this.sessionID = undefined; this.sessionID = null;
/** /**
* The previous heartbeat ping of the shard * The previous heartbeat ping of the shard
@@ -124,7 +124,7 @@ class WebSocketShard extends EventEmitter {
* @type {?NodeJS.Timeout} * @type {?NodeJS.Timeout}
* @private * @private
*/ */
Object.defineProperty(this, 'helloTimeout', { value: undefined, writable: true }); Object.defineProperty(this, 'helloTimeout', { value: null, writable: true });
/** /**
* If the manager attached its event handlers on the shard * If the manager attached its event handlers on the shard
@@ -140,7 +140,7 @@ class WebSocketShard extends EventEmitter {
* @type {?Set<string>} * @type {?Set<string>}
* @private * @private
*/ */
Object.defineProperty(this, 'expectedGuilds', { value: undefined, writable: true }); Object.defineProperty(this, 'expectedGuilds', { value: null, writable: true });
/** /**
* The ready timeout * The ready timeout
@@ -148,7 +148,7 @@ class WebSocketShard extends EventEmitter {
* @type {?NodeJS.Timeout} * @type {?NodeJS.Timeout}
* @private * @private
*/ */
Object.defineProperty(this, 'readyTimeout', { value: undefined, writable: true }); Object.defineProperty(this, 'readyTimeout', { value: null, writable: true });
/** /**
* Time when the WebSocket connection was opened * Time when the WebSocket connection was opened
@@ -428,7 +428,7 @@ class WebSocketShard extends EventEmitter {
// Reset the sequence // Reset the sequence
this.sequence = -1; this.sequence = -1;
// Reset the session ID as it's invalid // Reset the session ID as it's invalid
this.sessionID = undefined; this.sessionID = null;
// Set the status to reconnecting // Set the status to reconnecting
this.status = Status.RECONNECTING; this.status = Status.RECONNECTING;
// Finally, emit the INVALID_SESSION event // Finally, emit the INVALID_SESSION event
@@ -457,7 +457,7 @@ class WebSocketShard extends EventEmitter {
// Step 0. Clear the ready timeout, if it exists // Step 0. Clear the ready timeout, if it exists
if (this.readyTimeout) { if (this.readyTimeout) {
this.manager.client.clearTimeout(this.readyTimeout); this.manager.client.clearTimeout(this.readyTimeout);
this.readyTimeout = undefined; this.readyTimeout = null;
} }
// Step 1. If we don't have any other guilds pending, we are ready // Step 1. If we don't have any other guilds pending, we are ready
if (!this.expectedGuilds.size) { if (!this.expectedGuilds.size) {
@@ -480,7 +480,7 @@ class WebSocketShard extends EventEmitter {
this.debug(`Shard did not receive any more guild packets in 15 seconds. this.debug(`Shard did not receive any more guild packets in 15 seconds.
Unavailable guild count: ${this.expectedGuilds.size}`); Unavailable guild count: ${this.expectedGuilds.size}`);
this.readyTimeout = undefined; this.readyTimeout = null;
this.status = Status.READY; this.status = Status.READY;
@@ -498,7 +498,7 @@ class WebSocketShard extends EventEmitter {
if (this.helloTimeout) { if (this.helloTimeout) {
this.debug('Clearing the HELLO timeout.'); this.debug('Clearing the HELLO timeout.');
this.manager.client.clearTimeout(this.helloTimeout); this.manager.client.clearTimeout(this.helloTimeout);
this.helloTimeout = undefined; this.helloTimeout = null;
} }
return; return;
} }
@@ -519,7 +519,7 @@ class WebSocketShard extends EventEmitter {
if (this.heartbeatInterval) { if (this.heartbeatInterval) {
this.debug('Clearing the heartbeat interval.'); this.debug('Clearing the heartbeat interval.');
this.manager.client.clearInterval(this.heartbeatInterval); this.manager.client.clearInterval(this.heartbeatInterval);
this.heartbeatInterval = undefined; this.heartbeatInterval = null;
} }
return; return;
} }
@@ -734,7 +734,7 @@ class WebSocketShard extends EventEmitter {
// Step 5: Reset the sequence and session ID if requested // Step 5: Reset the sequence and session ID if requested
if (reset) { if (reset) {
this.sequence = -1; this.sequence = -1;
this.sessionID = undefined; this.sessionID = null;
} }
// Step 6: reset the ratelimit data // Step 6: reset the ratelimit data

View File

@@ -44,7 +44,7 @@ class Shard extends EventEmitter {
/** /**
* Arguments for the shard's process executable (only when {@link ShardingManager#mode} is `process`) * Arguments for the shard's process executable (only when {@link ShardingManager#mode} is `process`)
* @type {?string[]} * @type {string[]}
*/ */
this.execArgv = manager.execArgv; this.execArgv = manager.execArgv;
@@ -96,7 +96,7 @@ class Shard extends EventEmitter {
* @type {Function} * @type {Function}
* @private * @private
*/ */
this._exitListener = this._handleExit.bind(this, undefined); this._exitListener = this._handleExit.bind(this);
} }
/** /**

View File

@@ -125,7 +125,7 @@ class ShardClientUtil {
} }
/** /**
* Evaluates a script or function on all shards, in the context of the {@link Clients}. * Evaluates a script or function on all shards, in the context of the {@link Client}s.
* @param {string|Function} script JavaScript to run on each shard * @param {string|Function} script JavaScript to run on each shard
* @returns {Promise<Array<*>>} Results of the script execution * @returns {Promise<Array<*>>} Results of the script execution
* @example * @example

View File

@@ -4,6 +4,7 @@ const Util = require('../util/Util');
/** /**
* Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models). * Represents a data model that is identifiable by a Snowflake (i.e. Discord API data models).
* @abstract
*/ */
class Base { class Base {
constructor(client) { constructor(client) {

View File

@@ -5,6 +5,7 @@ const Emoji = require('./Emoji');
/** /**
* Parent class for {@link GuildEmoji} and {@link GuildPreviewEmoji}. * Parent class for {@link GuildEmoji} and {@link GuildPreviewEmoji}.
* @extends {Emoji} * @extends {Emoji}
* @abstract
*/ */
class BaseGuildEmoji extends Emoji { class BaseGuildEmoji extends Emoji {
constructor(client, data, guild) { constructor(client, data, guild) {
@@ -16,6 +17,10 @@ class BaseGuildEmoji extends Emoji {
*/ */
this.guild = guild; this.guild = guild;
this.requireColons = null;
this.managed = null;
this.available = null;
/** /**
* Array of role ids this emoji is active for * Array of role ids this emoji is active for
* @name BaseGuildEmoji#_roles * @name BaseGuildEmoji#_roles
@@ -30,26 +35,29 @@ class BaseGuildEmoji extends Emoji {
_patch(data) { _patch(data) {
if (data.name) this.name = data.name; if (data.name) this.name = data.name;
/** if (typeof data.require_colons !== 'undefined') {
* Whether or not this emoji requires colons surrounding it /**
* @type {?boolean} * Whether or not this emoji requires colons surrounding it
* @name GuildEmoji#requiresColons * @type {?boolean}
*/ */
if (typeof data.require_colons !== 'undefined') this.requiresColons = data.require_colons; this.requiresColons = data.require_colons;
}
/** if (typeof data.managed !== 'undefined') {
* Whether this emoji is managed by an external service /**
* @type {?boolean} * Whether this emoji is managed by an external service
* @name GuildEmoji#managed * @type {?boolean}
*/ */
if (typeof data.managed !== 'undefined') this.managed = data.managed; this.managed = data.managed;
}
/** if (typeof data.available !== 'undefined') {
* Whether this emoji is available /**
* @type {?boolean} * Whether this emoji is available
* @name GuildEmoji#available * @type {?boolean}
*/ */
if (typeof data.available !== 'undefined') this.available = data.available; this.available = data.available;
}
if (data.roles) this._roles = data.roles; if (data.roles) this._roles = data.roles;
} }

View File

@@ -7,6 +7,7 @@ const Snowflake = require('../util/Snowflake');
/** /**
* Represents any channel on Discord. * Represents any channel on Discord.
* @extends {Base} * @extends {Base}
* @abstract
*/ */
class Channel extends Base { class Channel extends Base {
constructor(client, data) { constructor(client, data) {

View File

@@ -231,36 +231,38 @@ class Guild extends Base {
*/ */
this.premiumTier = data.premium_tier; this.premiumTier = data.premium_tier;
/**
* The total number of boosts for this server
* @type {?number}
* @name Guild#premiumSubscriptionCount
*/
if (typeof data.premium_subscription_count !== 'undefined') { if (typeof data.premium_subscription_count !== 'undefined') {
/**
* The total number of boosts for this server
* @type {?number}
*/
this.premiumSubscriptionCount = data.premium_subscription_count; this.premiumSubscriptionCount = data.premium_subscription_count;
} }
/** if (typeof data.widget_enabled !== 'undefined') {
* Whether widget images are enabled on this guild /**
* @type {?boolean} * Whether widget images are enabled on this guild
* @name Guild#widgetEnabled * @type {?boolean}
*/ */
if (typeof data.widget_enabled !== 'undefined') this.widgetEnabled = data.widget_enabled; this.widgetEnabled = data.widget_enabled;
}
/** if (typeof data.widget_channel_id !== 'undefined') {
* The widget channel ID, if enabled /**
* @type {?string} * The widget channel ID, if enabled
* @name Guild#widgetChannelID * @type {?string}
*/ */
if (typeof data.widget_channel_id !== 'undefined') this.widgetChannelID = data.widget_channel_id; this.widgetChannelID = data.widget_channel_id;
}
/** if (typeof data.embed_channel_id !== 'undefined') {
* The embed channel ID, if enabled /**
* @type {?string} * The embed channel ID, if enabled
* @name Guild#embedChannelID * @type {?string}
* @deprecated * @deprecated
*/ */
if (typeof data.embed_channel_id !== 'undefined') this.embedChannelID = data.embed_channel_id; this.embedChannelID = data.embed_channel_id;
}
/** /**
* The verification level of the guild * The verification level of the guild
@@ -299,40 +301,47 @@ class Guild extends Base {
*/ */
this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze(); this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze();
/** if (typeof data.max_members !== 'undefined') {
* The maximum amount of members the guild can have /**
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info> * The maximum amount of members the guild can have
* @type {?number} * @type {?number}
* @name Guild#maximumMembers */
*/ this.maximumMembers = data.max_members;
if (typeof data.max_members !== 'undefined') this.maximumMembers = data.max_members || 250000; } else if (typeof this.maximumMembers === 'undefined') {
this.maximumMembers = null;
/** }
* The maximum amount of presences the guild can have
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info> if (typeof data.max_presences !== 'undefined') {
* @type {?number} /**
* @name Guild#maximumPresences * The maximum amount of presences the guild can have
*/ * <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 25000; * @type {?number}
*/
/** this.maximumPresences = data.max_presences || 25000;
* The approximate amount of members the guild has } else if (typeof this.maximumPresences === 'undefined') {
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info> this.maximumPresences = null;
* @type {?number} }
* @name Guild#approximateMemberCount
*/ if (typeof data.approximate_member_count !== 'undefined') {
if (typeof data.approximate_member_count !== 'undefined') { /**
this.approximateMemberCount = data.approximate_member_count; * The approximate amount of members the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number}
*/
this.approximateMemberCount = data.approximate_member_count;
} else if (typeof this.approximateMemberCount === 'undefined') {
this.approximateMemberCount = null;
} }
/**
* The approximate amount of presences the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number}
* @name Guild#approximatePresenceCount
*/
if (typeof data.approximate_presence_count !== 'undefined') { if (typeof data.approximate_presence_count !== 'undefined') {
/**
* The approximate amount of presences the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number}
*/
this.approximatePresenceCount = data.approximate_presence_count; this.approximatePresenceCount = data.approximate_presence_count;
} else if (typeof this.approximatePresenceCount === 'undefined') {
this.approximatePresenceCount = null;
} }
/** /**

View File

@@ -24,7 +24,7 @@ const Util = require('../util/Util');
/** /**
* Key mirror of all available audit log targets. * Key mirror of all available audit log targets.
* @name GuildAuditLogs.Targets * @name GuildAuditLogs.Targets
* @type {AuditLogTargetType} * @type {Object<string, string>}
*/ */
const Targets = { const Targets = {
ALL: 'ALL', ALL: 'ALL',
@@ -84,7 +84,7 @@ const Targets = {
/** /**
* All available actions keyed under their names to their numeric values. * All available actions keyed under their names to their numeric values.
* @name GuildAuditLogs.Actions * @name GuildAuditLogs.Actions
* @type {AuditLogAction} * @type {Object<string, number>}
*/ */
const Actions = { const Actions = {
ALL: null, ALL: null,

View File

@@ -17,6 +17,7 @@ const Util = require('../util/Util');
* - {@link NewsChannel} * - {@link NewsChannel}
* - {@link StoreChannel} * - {@link StoreChannel}
* @extends {Channel} * @extends {Channel}
* @abstract
*/ */
class GuildChannel extends Channel { class GuildChannel extends Channel {
/** /**
@@ -31,6 +32,8 @@ class GuildChannel extends Channel {
* @type {Guild} * @type {Guild}
*/ */
this.guild = guild; this.guild = guild;
this.parentID = null;
} }
_patch(data) { _patch(data) {
@@ -298,7 +301,7 @@ class GuildChannel extends Channel {
* @property {boolean} [nsfw] Whether the channel is NSFW * @property {boolean} [nsfw] Whether the channel is NSFW
* @property {number} [bitrate] The bitrate of the voice channel * @property {number} [bitrate] The bitrate of the voice channel
* @property {number} [userLimit] The user limit of the voice channel * @property {number} [userLimit] The user limit of the voice channel
* @property {Snowflake} [parentID] The parent ID of the channel * @property {?Snowflake} [parentID] The parent ID of the channel
* @property {boolean} [lockPermissions] * @property {boolean} [lockPermissions]
* Lock the permissions of the channel to what the parent's permissions are * Lock the permissions of the channel to what the parent's permissions are
* @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites] * @property {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [permissionOverwrites]

View File

@@ -61,7 +61,6 @@ class GuildMember extends Base {
/** /**
* The nickname of this member, if they have one * The nickname of this member, if they have one
* @type {?string} * @type {?string}
* @name GuildMember#nickname
*/ */
this.nickname = null; this.nickname = null;
@@ -74,7 +73,6 @@ class GuildMember extends Base {
/** /**
* The user that this guild member instance represents * The user that this guild member instance represents
* @type {User} * @type {User}
* @name GuildMember#user
*/ */
this.user = this.client.users.add(data.user, true); this.user = this.client.users.add(data.user, true);
} }

View File

@@ -75,7 +75,7 @@ class GuildPreview extends Base {
* The description for this guild * The description for this guild
* @type {?string} * @type {?string}
*/ */
this.description = data.description; this.description = data.description || null;
if (!this.emojis) { if (!this.emojis) {
/** /**

View File

@@ -65,6 +65,8 @@ class Integration extends Base {
* @type {?User} * @type {?User}
*/ */
this.user = this.client.users.add(data.user); this.user = this.client.users.add(data.user);
} else {
this.user = null;
} }
/** /**

View File

@@ -29,37 +29,37 @@ class MessageEmbed {
* * `link` - a link embed * * `link` - a link embed
* @type {string} * @type {string}
*/ */
this.type = data.type; this.type = data.type || 'rich';
/** /**
* The title of this embed * The title of this embed
* @type {?string} * @type {?string}
*/ */
this.title = data.title; this.title = 'title' in data ? data.title : null;
/** /**
* The description of this embed * The description of this embed
* @type {?string} * @type {?string}
*/ */
this.description = data.description; this.description = 'description' in data ? data.description : null;
/** /**
* The URL of this embed * The URL of this embed
* @type {?string} * @type {?string}
*/ */
this.url = data.url; this.url = 'url' in data ? data.url : null;
/** /**
* The color of this embed * The color of this embed
* @type {?number} * @type {?number}
*/ */
this.color = Util.resolveColor(data.color); this.color = 'color' in data ? Util.resolveColor(data.color) : null;
/** /**
* The timestamp of this embed * The timestamp of this embed
* @type {?number} * @type {?number}
*/ */
this.timestamp = data.timestamp ? new Date(data.timestamp).getTime() : null; this.timestamp = 'timestamp' in data ? new Date(data.timestamp).getTime() : null;
/** /**
* Represents a field of a MessageEmbed * Represents a field of a MessageEmbed
@@ -331,7 +331,7 @@ class MessageEmbed {
*/ */
setFooter(text, iconURL) { setFooter(text, iconURL) {
text = Util.resolveString(text); text = Util.resolveString(text);
this.footer = { text, iconURL, proxyIconURL: undefined }; this.footer = { text, iconURL };
return this; return this;
} }

View File

@@ -46,13 +46,14 @@ class MessageReaction {
} }
_patch(data) { _patch(data) {
/**
* The number of people that have given the same reaction
* @type {?number}
* @name MessageReaction#count
*/
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
if (this.count == undefined) this.count = data.count; if (this.count == undefined) {
/**
* The number of people that have given the same reaction
* @type {?number}
*/
this.count = data.count;
}
} }
/** /**

View File

@@ -184,8 +184,8 @@ class Activity {
/** /**
* Timestamps for the activity * Timestamps for the activity
* @type {?Object} * @type {?Object}
* @prop {?Date} start When the activity started * @property {?Date} start When the activity started
* @prop {?Date} end When the activity will end * @property {?Date} end When the activity will end
*/ */
this.timestamps = data.timestamps this.timestamps = data.timestamps
? { ? {
@@ -197,8 +197,8 @@ class Activity {
/** /**
* Party of the activity * Party of the activity
* @type {?Object} * @type {?Object}
* @prop {?string} id ID of the party * @property {?string} id ID of the party
* @prop {number[]} size Size of the party as `[current, max]` * @property {number[]} size Size of the party as `[current, max]`
*/ */
this.party = data.party || null; this.party = data.party || null;

View File

@@ -27,6 +27,10 @@ class User extends Base {
*/ */
this.id = data.id; this.id = data.id;
this.system = null;
this.locale = null;
this.flags = null;
this._patch(data); this._patch(data);
} }
@@ -35,7 +39,6 @@ class User extends Base {
/** /**
* The username of the user * The username of the user
* @type {?string} * @type {?string}
* @name User#username
*/ */
this.username = data.username; this.username = data.username;
} else if (typeof this.username !== 'string') { } else if (typeof this.username !== 'string') {
@@ -45,7 +48,6 @@ class User extends Base {
/** /**
* Whether or not the user is a bot * Whether or not the user is a bot
* @type {boolean} * @type {boolean}
* @name User#bot
*/ */
this.bot = Boolean(data.bot); this.bot = Boolean(data.bot);
@@ -53,7 +55,6 @@ class User extends Base {
/** /**
* A discriminator based on username for the user * A discriminator based on username for the user
* @type {?string} * @type {?string}
* @name User#discriminator
*/ */
this.discriminator = data.discriminator; this.discriminator = data.discriminator;
} else if (typeof this.discriminator !== 'string') { } else if (typeof this.discriminator !== 'string') {
@@ -64,7 +65,6 @@ class User extends Base {
/** /**
* The ID of the user's avatar * The ID of the user's avatar
* @type {?string} * @type {?string}
* @name User#avatar
*/ */
this.avatar = data.avatar; this.avatar = data.avatar;
} else if (typeof this.avatar !== 'string') { } else if (typeof this.avatar !== 'string') {
@@ -75,7 +75,6 @@ class User extends Base {
/** /**
* Whether the user is an Official Discord System user (part of the urgent message system) * Whether the user is an Official Discord System user (part of the urgent message system)
* @type {?boolean} * @type {?boolean}
* @name User#system
*/ */
this.system = Boolean(data.system); this.system = Boolean(data.system);
} }
@@ -84,7 +83,6 @@ class User extends Base {
/** /**
* The locale of the user's client (ISO 639-1) * The locale of the user's client (ISO 639-1)
* @type {?string} * @type {?string}
* @name User#locale
*/ */
this.locale = data.locale; this.locale = data.locale;
} }
@@ -93,7 +91,6 @@ class User extends Base {
/** /**
* The flags for this user * The flags for this user
* @type {?UserFlags} * @type {?UserFlags}
* @name User#flags
*/ */
this.flags = new UserFlags(data.public_flags); this.flags = new UserFlags(data.public_flags);
} }

View File

@@ -29,7 +29,6 @@ class VoiceChannel extends GuildChannel {
/** /**
* The members in this voice channel * The members in this voice channel
* @type {Collection<Snowflake, GuildMember>} * @type {Collection<Snowflake, GuildMember>}
* @name VoiceChannel#members
* @readonly * @readonly
*/ */
get members() { get members() {

View File

@@ -32,32 +32,32 @@ class VoiceState extends Base {
* Whether this member is deafened server-wide * Whether this member is deafened server-wide
* @type {?boolean} * @type {?boolean}
*/ */
this.serverDeaf = data.deaf; this.serverDeaf = 'deaf' in data ? data.deaf : null;
/** /**
* Whether this member is muted server-wide * Whether this member is muted server-wide
* @type {?boolean} * @type {?boolean}
*/ */
this.serverMute = data.mute; this.serverMute = 'mute' in data ? data.mute : null;
/** /**
* Whether this member is self-deafened * Whether this member is self-deafened
* @type {?boolean} * @type {?boolean}
*/ */
this.selfDeaf = data.self_deaf; this.selfDeaf = 'self_deaf' in data ? data.self_deaf : null;
/** /**
* Whether this member is self-muted * Whether this member is self-muted
* @type {?boolean} * @type {?boolean}
*/ */
this.selfMute = data.self_mute; this.selfMute = 'self_mute' in data ? data.self_mute : null;
/** /**
* Whether this member's camera is enabled * Whether this member's camera is enabled
* @type {boolean} * @type {?boolean}
*/ */
this.selfVideo = data.self_video; this.selfVideo = 'self_video' in data ? data.self_video : null;
/** /**
* 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 = 'session_id' in data ? data.session_id : null;
/** /**
* Whether this member is streaming using "Go Live" * Whether this member is streaming using "Go Live"
* @type {boolean} * @type {boolean}
@@ -67,7 +67,7 @@ class VoiceState extends Base {
* 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 || null;
return this; return this;
} }

64
typings/index.d.ts vendored
View File

@@ -142,13 +142,13 @@ declare module 'discord.js' {
constructor(client: Client, data: object, guild: Guild); constructor(client: Client, data: object, guild: Guild);
private _roles: string[]; private _roles: string[];
public available?: boolean; public available: boolean | null;
public readonly createdAt: Date; public readonly createdAt: Date;
public readonly createdTimestamp: number; public readonly createdTimestamp: number;
public guild: Guild | GuildPreview; public guild: Guild | GuildPreview;
public id: Snowflake; public id: Snowflake;
public managed?: boolean; public managed: boolean | null;
public requiresColons?: boolean; public requiresColons: boolean | null;
} }
class BroadcastDispatcher extends VolumeMixin(StreamDispatcher) { class BroadcastDispatcher extends VolumeMixin(StreamDispatcher) {
@@ -625,8 +625,8 @@ declare module 'discord.js' {
public afkChannelID: Snowflake | null; public afkChannelID: Snowflake | null;
public afkTimeout: number; public afkTimeout: number;
public applicationID: Snowflake | null; public applicationID: Snowflake | null;
public approximateMemberCount?: number; public approximateMemberCount: number | null;
public approximatePresenceCount?: number; public approximatePresenceCount: number | null;
public available: boolean; public available: boolean;
public banner: string | null; public banner: string | null;
public channels: GuildChannelManager; public channels: GuildChannelManager;
@@ -818,7 +818,7 @@ declare module 'discord.js' {
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null; public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
public setName(name: string, reason?: string): Promise<this>; public setName(name: string, reason?: string): Promise<this>;
public setParent( public setParent(
channel: CategoryChannel | Snowflake, channel: CategoryChannel | Snowflake | null,
options?: { lockPermissions?: boolean; reason?: string }, options?: { lockPermissions?: boolean; reason?: string },
): Promise<this>; ): Promise<this>;
public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise<this>; public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise<this>;
@@ -932,7 +932,7 @@ declare module 'discord.js' {
public syncedAt: number; public syncedAt: number;
public syncing: boolean; public syncing: boolean;
public type: string; public type: string;
public user?: User; public user: User | null;
public delete(reason?: string): Promise<Integration>; public delete(reason?: string): Promise<Integration>;
public edit(data: IntegrationEditData, reason?: string): Promise<Integration>; public edit(data: IntegrationEditData, reason?: string): Promise<Integration>;
public sync(): Promise<Integration>; public sync(): Promise<Integration>;
@@ -1054,7 +1054,7 @@ declare module 'discord.js' {
public attachment: BufferResolvable | Stream; public attachment: BufferResolvable | Stream;
public height: number | null; public height: number | null;
public id: Snowflake; public id: Snowflake;
public name?: string; public name: string | null;
public proxyURL: string; public proxyURL: string;
public size: number; public size: number;
public readonly spoiler: boolean; public readonly spoiler: boolean;
@@ -1082,9 +1082,9 @@ declare module 'discord.js' {
export class MessageEmbed { export class MessageEmbed {
constructor(data?: MessageEmbed | MessageEmbedOptions); constructor(data?: MessageEmbed | MessageEmbedOptions);
public author: MessageEmbedAuthor | null; public author: MessageEmbedAuthor | null;
public color?: number; public color: number | null;
public readonly createdAt: Date | null; public readonly createdAt: Date | null;
public description?: string; public description: string | null;
public fields: EmbedField[]; public fields: EmbedField[];
public files: (MessageAttachment | string | FileOptions)[]; public files: (MessageAttachment | string | FileOptions)[];
public footer: MessageEmbedFooter | null; public footer: MessageEmbedFooter | null;
@@ -1094,9 +1094,9 @@ declare module 'discord.js' {
public provider: MessageEmbedProvider | null; public provider: MessageEmbedProvider | null;
public thumbnail: MessageEmbedThumbnail | null; public thumbnail: MessageEmbedThumbnail | null;
public timestamp: number | null; public timestamp: number | null;
public title?: string; public title: string | null;
public type: string; public type: string;
public url?: string; public url: string | null;
public readonly video: MessageEmbedVideo | null; public readonly video: MessageEmbedVideo | null;
public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this; public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this;
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this; public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
@@ -1540,13 +1540,13 @@ declare module 'discord.js' {
public discriminator: string; public discriminator: string;
public readonly defaultAvatarURL: string; public readonly defaultAvatarURL: string;
public readonly dmChannel: DMChannel | null; public readonly dmChannel: DMChannel | null;
public flags?: Readonly<UserFlags>; public flags: Readonly<UserFlags> | null;
public id: Snowflake; public id: Snowflake;
public lastMessageID: Snowflake | null; public lastMessageID: Snowflake | null;
public locale?: string; public locale: string | null;
public readonly partial: false; public readonly partial: false;
public readonly presence: Presence; public readonly presence: Presence;
public system?: boolean; public system: boolean | null;
public readonly tag: string; public readonly tag: string;
public username: string; public username: string;
public avatarURL(options?: ImageURLOptions & { dynamic?: boolean }): string | null; public avatarURL(options?: ImageURLOptions & { dynamic?: boolean }): string | null;
@@ -1613,7 +1613,7 @@ declare module 'discord.js' {
constructor(client: Client); constructor(client: Client);
public client: Client; public client: Client;
public subscribers: StreamDispatcher[]; public subscribers: StreamDispatcher[];
public readonly dispatcher?: BroadcastDispatcher; public readonly dispatcher: BroadcastDispatcher | null;
public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher; public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher;
public end(): void; public end(): void;
@@ -1669,7 +1669,7 @@ declare module 'discord.js' {
public receiver: VoiceReceiver; public receiver: VoiceReceiver;
public speaking: Readonly<Speaking>; public speaking: Readonly<Speaking>;
public status: VoiceStatus; public status: VoiceStatus;
public readonly voice: VoiceState; public readonly voice: VoiceState | null;
public voiceManager: ClientVoiceManager; public voiceManager: ClientVoiceManager;
public disconnect(): void; public disconnect(): void;
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher; public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;
@@ -1721,18 +1721,18 @@ declare module 'discord.js' {
export class VoiceState extends Base { export class VoiceState extends Base {
constructor(guild: Guild, data: object); constructor(guild: Guild, data: object);
public readonly channel: VoiceChannel | null; public readonly channel: VoiceChannel | null;
public channelID?: Snowflake; public channelID: Snowflake | null;
public readonly connection: VoiceConnection | null; public readonly connection: VoiceConnection | null;
public readonly deaf?: boolean; public readonly deaf: boolean | null;
public guild: Guild; public guild: Guild;
public id: Snowflake; public id: Snowflake;
public readonly member: GuildMember | null; public readonly member: GuildMember | null;
public readonly mute?: boolean; public readonly mute: boolean | null;
public selfDeaf?: boolean; public selfDeaf: boolean | null;
public selfMute?: boolean; public selfMute: boolean | null;
public serverDeaf?: boolean; public serverDeaf: boolean | null;
public serverMute?: boolean; public serverMute: boolean | null;
public sessionID?: string; public sessionID: string | null;
public streaming: boolean; public streaming: boolean;
public selfVideo: boolean; public selfVideo: boolean;
public readonly speaking: boolean | null; public readonly speaking: boolean | null;
@@ -1786,10 +1786,10 @@ declare module 'discord.js' {
private packetQueue: object[]; private packetQueue: object[];
private destroyed: boolean; private destroyed: boolean;
private reconnecting: boolean; private reconnecting: boolean;
private sessionStartLimit?: { total: number; remaining: number; reset_after: number }; private sessionStartLimit: { total: number; remaining: number; reset_after: number } | null;
public readonly client: Client; public readonly client: Client;
public gateway?: string; public gateway: string | null;
public shards: Collection<number, WebSocketShard>; public shards: Collection<number, WebSocketShard>;
public status: Status; public status: Status;
public readonly ping: number; public readonly ping: number;
@@ -1813,15 +1813,15 @@ declare module 'discord.js' {
constructor(manager: WebSocketManager, id: number); constructor(manager: WebSocketManager, id: number);
private sequence: number; private sequence: number;
private closeSequence: number; private closeSequence: number;
private sessionID?: string; private sessionID: string | null;
private lastPingTimestamp: number; private lastPingTimestamp: number;
private lastHeartbeatAcked: boolean; private lastHeartbeatAcked: boolean;
private ratelimit: { queue: object[]; total: number; remaining: number; time: 60e3; timer: NodeJS.Timeout | null }; private ratelimit: { queue: object[]; total: number; remaining: number; time: 60e3; timer: NodeJS.Timeout | null };
private connection: WebSocket | null; private connection: WebSocket | null;
private helloTimeout: NodeJS.Timeout | undefined; private helloTimeout: NodeJS.Timeout | null;
private eventsAttached: boolean; private eventsAttached: boolean;
private expectedGuilds: Set<Snowflake> | undefined; private expectedGuilds: Set<Snowflake> | null;
private readyTimeout: NodeJS.Timeout | undefined; private readyTimeout: NodeJS.Timeout | null;
public manager: WebSocketManager; public manager: WebSocketManager;
public id: number; public id: number;
@@ -2234,7 +2234,7 @@ declare module 'discord.js' {
nsfw?: boolean; nsfw?: boolean;
bitrate?: number; bitrate?: number;
userLimit?: number; userLimit?: number;
parentID?: Snowflake; parentID?: Snowflake | null;
rateLimitPerUser?: number; rateLimitPerUser?: number;
lockPermissions?: boolean; lockPermissions?: boolean;
permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>; permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;