Improve docs a bit

This commit is contained in:
Crawl
2017-04-30 04:30:44 +02:00
parent 3f8c0a4d11
commit ac92d2cecc
83 changed files with 716 additions and 711 deletions

View File

@@ -5,7 +5,7 @@
// Import the discord.js module
const Discord = require('discord.js');
// Create an instance of a Discord Client
// Create an instance of a Discord client
const client = new Discord.Client();
// The token of your bot - https://discordapp.com/developers/applications/me

View File

@@ -5,7 +5,7 @@
// Import the discord.js module
const Discord = require('discord.js');
// Create an instance of a Discord Client
// Create an instance of a Discord client
const client = new Discord.Client();
// The token of your bot - https://discordapp.com/developers/applications/me

View File

@@ -5,7 +5,7 @@
// Import the discord.js module
const Discord = require('discord.js');
// Create an instance of a Discord Client
// Create an instance of a Discord client
const client = new Discord.Client();
// The token of your bot - https://discordapp.com/developers/applications/me

View File

@@ -347,7 +347,7 @@ class Client extends EventEmitter {
* Sweeps all text-based channels' messages and removes the ones older than the max message lifetime.
* If the message has been edited, the time of the edit is used rather than the time of the original message.
* @param {number} [lifetime=this.options.messageCacheLifetime] Messages that are older than this (in seconds)
* will be removed from the caches. The default is based on {@link ClientOptions#messageCacheLifetime}.
* will be removed from the caches. The default is based on {@link ClientOptions#messageCacheLifetime}
* @returns {number} Amount of messages that were removed from the caches,
* or -1 if the message cache lifetime is unlimited
*/
@@ -535,13 +535,13 @@ class Client extends EventEmitter {
module.exports = Client;
/**
* Emitted for general warnings
* Emitted for general warnings.
* @event Client#warn
* @param {string} info The warning
*/
/**
* Emitted for general debugging information
* Emitted for general debugging information.
* @event Client#debug
* @param {string} info The debug information
*/

View File

@@ -36,7 +36,7 @@ class ClientDataResolver {
*/
/**
* Resolves a UserResolvable to a User object
* Resolves a UserResolvable to a User object.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?User}
*/
@@ -50,7 +50,7 @@ class ClientDataResolver {
}
/**
* Resolves a UserResolvable to a user ID string
* Resolves a UserResolvable to a user ID string.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?Snowflake}
*/
@@ -70,7 +70,7 @@ class ClientDataResolver {
*/
/**
* Resolves a GuildResolvable to a Guild object
* Resolves a GuildResolvable to a Guild object.
* @param {GuildResolvable} guild The GuildResolvable to identify
* @returns {?Guild}
*/
@@ -88,7 +88,7 @@ class ClientDataResolver {
*/
/**
* Resolves a GuildMemberResolvable to a GuildMember object
* Resolves a GuildMemberResolvable to a GuildMember object.
* @param {GuildResolvable} guild The guild that the member is part of
* @param {UserResolvable} user The user that is part of the guild
* @returns {?GuildMember}
@@ -111,7 +111,7 @@ class ClientDataResolver {
*/
/**
* Resolves a ChannelResolvable to a Channel object
* Resolves a ChannelResolvable to a Channel object.
* @param {ChannelResolvable} channel The channel resolvable to resolve
* @returns {?Channel}
*/
@@ -124,7 +124,7 @@ class ClientDataResolver {
}
/**
* Resolves a ChannelResolvable to a channel ID
* Resolves a ChannelResolvable to a channel ID.
* @param {ChannelResolvable} channel The channel resolvable to resolve
* @returns {?Snowflake}
*/
@@ -144,7 +144,7 @@ class ClientDataResolver {
*/
/**
* Resolves InviteResolvable to an invite code
* Resolves InviteResolvable to an invite code.
* @param {InviteResolvable} data The invite resolvable to resolve
* @returns {string}
*/
@@ -164,7 +164,7 @@ class ClientDataResolver {
*/
/**
* Resolves a StringResolvable to a string
* Resolves a StringResolvable to a string.
* @param {StringResolvable} data The string resolvable to resolve
* @returns {string}
*/
@@ -182,7 +182,7 @@ class ClientDataResolver {
*/
/**
* Resolves a Base64Resolvable to a Base 64 image
* Resolves a Base64Resolvable to a Base 64 image.
* @param {Base64Resolvable} data The base 64 resolvable you want to resolve
* @returns {?string}
*/
@@ -200,7 +200,7 @@ class ClientDataResolver {
*/
/**
* Resolves a BufferResolvable to a Buffer
* Resolves a BufferResolvable to a Buffer.
* @param {BufferResolvable} resource The buffer resolvable to resolve
* @returns {Promise<Buffer>}
*/
@@ -244,7 +244,7 @@ class ClientDataResolver {
*/
/**
* Resolves an EmojiResolvable to an emoji identifier
* Resolves an EmojiResolvable to an emoji identifier.
* @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve
* @returns {?string}
*/
@@ -295,7 +295,7 @@ class ClientDataResolver {
*/
/**
* Resolves a ColorResolvable into a color number
* Resolves a ColorResolvable into a color number.
* @param {ColorResolvable} color Color to resolve
* @returns {number} A color
*/

View File

@@ -2,19 +2,19 @@ const Constants = require('../util/Constants');
const WebSocketConnection = require('./websocket/WebSocketConnection');
/**
* Manages the State and Background Tasks of the Client
* Manages the state and background tasks of the client.
* @private
*/
class ClientManager {
constructor(client) {
/**
* The Client that instantiated this Manager
* The client that instantiated this Manager
* @type {Client}
*/
this.client = client;
/**
* The heartbeat interval, null if not yet set
* The heartbeat interval
* @type {?number}
*/
this.heartbeatInterval = null;
@@ -29,7 +29,7 @@ class ClientManager {
}
/**
* Connects the Client to the WebSocket
* Connects the client to the WebSocket.
* @param {string} token The authorization token
* @param {Function} resolve Function to run when connection is successful
* @param {Function} reject Function to run when connection fails

View File

@@ -5,7 +5,7 @@ const Constants = require('../util/Constants');
const Util = require('../util/Util');
/**
* The Webhook Client
* The webhook client.
* @extends {Webhook}
*/
class WebhookClient extends Webhook {
@@ -14,7 +14,7 @@ class WebhookClient extends Webhook {
* @param {string} token Token of the webhook
* @param {ClientOptions} [options] Options for the client
* @example
* // create a new webhook and send a message
* // Create a new webhook and send a message
* const hook = new Discord.WebhookClient('1234', 'abcdef');
* hook.sendMessage('This will send a message').catch(console.error);
*/

View File

@@ -47,7 +47,7 @@ class GuildDeleteAction extends Action {
/**
* Emitted whenever a guild becomes unavailable, likely due to a server outage.
* @event Client#guildUnavailable
* @param {Guild} guild The guild that has become unavailable.
* @param {Guild} guild The guild that has become unavailable
*/
module.exports = GuildDeleteAction;

View File

@@ -9,9 +9,9 @@ class GuildEmojiCreateAction extends Action {
}
/**
* Emitted whenever a custom emoji is created in a guild
* Emitted whenever a custom emoji is created in a guild.
* @event Client#emojiCreate
* @param {Emoji} emoji The emoji that was created.
* @param {Emoji} emoji The emoji that was created
*/
module.exports = GuildEmojiCreateAction;

View File

@@ -9,9 +9,9 @@ class GuildEmojiDeleteAction extends Action {
}
/**
* Emitted whenever a custom guild emoji is deleted
* Emitted whenever a custom guild emoji is deleted.
* @event Client#emojiDelete
* @param {Emoji} emoji The emoji that was deleted.
* @param {Emoji} emoji The emoji that was deleted
*/
module.exports = GuildEmojiDeleteAction;

View File

@@ -8,7 +8,7 @@ class GuildEmojiUpdateAction extends Action {
}
/**
* Emitted whenever a custom guild emoji is updated
* Emitted whenever a custom guild emoji is updated.
* @event Client#emojiUpdate
* @param {Emoji} oldEmoji The old emoji
* @param {Emoji} newEmoji The new emoji

View File

@@ -34,7 +34,7 @@ class GuildMemberRemoveAction extends Action {
/**
* Emitted whenever a member leaves a guild, or is kicked.
* @event Client#guildMemberRemove
* @param {GuildMember} member The member that has left/been kicked from the guild.
* @param {GuildMember} member The member that has left/been kicked from the guild
*/
module.exports = GuildMemberRemoveAction;

View File

@@ -20,7 +20,7 @@ class GuildRoleCreate extends Action {
/**
* Emitted whenever a role is created.
* @event Client#roleCreate
* @param {Role} role The role that was created.
* @param {Role} role The role that was created
*/
module.exports = GuildRoleCreate;

View File

@@ -35,7 +35,7 @@ class GuildRoleDeleteAction extends Action {
/**
* Emitted whenever a guild role is deleted.
* @event Client#roleDelete
* @param {Role} role The role that was deleted.
* @param {Role} role The role that was deleted
*/
module.exports = GuildRoleDeleteAction;

View File

@@ -34,8 +34,8 @@ class GuildRoleUpdateAction extends Action {
/**
* Emitted whenever a guild role is updated.
* @event Client#roleUpdate
* @param {Role} oldRole The role before the update.
* @param {Role} newRole The role after the update.
* @param {Role} oldRole The role before the update
* @param {Role} newRole The role after the update
*/
module.exports = GuildRoleUpdateAction;

View File

@@ -27,8 +27,8 @@ class GuildUpdateAction extends Action {
/**
* Emitted whenever a guild is updated - e.g. name change.
* @event Client#guildUpdate
* @param {Guild} oldGuild The guild before the update.
* @param {Guild} newGuild The guild after the update.
* @param {Guild} oldGuild The guild before the update
* @param {Guild} newGuild The guild after the update
*/
module.exports = GuildUpdateAction;

View File

@@ -30,8 +30,8 @@ class MessageReactionAdd extends Action {
/**
* Emitted whenever a reaction is added to a message.
* @event Client#messageReactionAdd
* @param {MessageReaction} messageReaction The reaction object.
* @param {User} user The user that applied the emoji or reaction emoji.
* @param {MessageReaction} messageReaction The reaction object
* @param {User} user The user that applied the emoji or reaction emoji
*/
module.exports = MessageReactionAdd;

View File

@@ -30,8 +30,8 @@ class MessageReactionRemove extends Action {
/**
* Emitted whenever a reaction is removed from a message.
* @event Client#messageReactionRemove
* @param {MessageReaction} messageReaction The reaction object.
* @param {User} user The user that removed the emoji or reaction emoji.
* @param {MessageReaction} messageReaction The reaction object
* @param {User} user The user that removed the emoji or reaction emoji
*/
module.exports = MessageReactionRemove;

View File

@@ -19,7 +19,7 @@ class MessageReactionRemoveAll extends Action {
/**
* Emitted whenever all reactions are removed from a message.
* @event Client#messageReactionRemoveAll
* @param {Message} message The message the reactions were removed from.
* @param {Message} message The message the reactions were removed from
*/
module.exports = MessageReactionRemoveAll;

View File

@@ -33,8 +33,8 @@ class MessageUpdateAction extends Action {
/**
* Emitted whenever a message is updated - e.g. embed or content change.
* @event Client#messageUpdate
* @param {Message} oldMessage The message before the update.
* @param {Message} newMessage The message after the update.
* @param {Message} oldMessage The message before the update
* @param {Message} newMessage The message after the update
*/
module.exports = MessageUpdateAction;

View File

@@ -1,5 +1,5 @@
/**
* Represents an error from the Discord API
* Represents an error from the Discord API.
*/
class DiscordAPIError extends Error {
constructor(error) {
@@ -16,7 +16,7 @@ class DiscordAPIError extends Error {
}
/**
* Flattens an errors object returned from the API into an array
* Flattens an errors object returned from the API into an array.
* @param {Object} obj Discord errors object
* @param {string} [key] idklol
* @returns {string[]}

View File

@@ -14,14 +14,14 @@ class RequestHandler {
this.restManager = restManager;
/**
* A list of requests that have yet to be processed.
* A list of requests that have yet to be processed
* @type {APIRequest[]}
*/
this.queue = [];
}
/**
* Whether or not the client is being rate limited on every endpoint.
* Whether or not the client is being rate limited on every endpoint
* @type {boolean}
* @readonly
*/
@@ -34,7 +34,7 @@ class RequestHandler {
}
/**
* Push a new API request into this bucket
* Push a new API request into this bucket.
* @param {APIRequest} request The new request to push into the queue
*/
push(request) {
@@ -42,7 +42,7 @@ class RequestHandler {
}
/**
* Attempts to get this RequestHandler to process its current queue
* Attempts to get this RequestHandler to process its current queue.
*/
handle() {} // eslint-disable-line no-empty-function

View File

@@ -24,7 +24,7 @@ class SequentialRequestHandler extends RequestHandler {
/**
* The time difference between Discord's Dates and the local computer's Dates. A positive number means the local
* computer's time is ahead of Discord's.
* computer's time is ahead of Discord's
* @type {number}
*/
this.timeDifference = 0;
@@ -42,7 +42,7 @@ class SequentialRequestHandler extends RequestHandler {
}
/**
* Performs a request then resolves a promise to indicate its readiness for a new request
* Performs a request then resolves a promise to indicate its readiness for a new request.
* @param {APIRequest} item The item to execute
* @returns {Promise<?Object|Error>}
*/

View File

@@ -2,7 +2,7 @@ const Collection = require('../../util/Collection');
const VoiceConnection = require('./VoiceConnection');
/**
* Manages all the voice stuff for the Client
* Manages all the voice stuff for the client.
* @private
*/
class ClientVoiceManager {
@@ -37,7 +37,7 @@ class ClientVoiceManager {
}
/**
* Sets up a request to join a voice channel
* Sets up a request to join a voice channel.
* @param {VoiceChannel} channel The voice channel to join
* @returns {Promise<VoiceConnection>}
*/

View File

@@ -64,7 +64,7 @@ class VoiceBroadcast extends VolumeInterface {
const volume = old || dispatcher.volume;
/**
* Emitted whenever a stream dispatcher unsubscribes from the broadcast
* Emitted whenever a stream dispatcher unsubscribes from the broadcast.
* @event VoiceBroadcast#unsubscribe
* @param {StreamDispatcher} dispatcher The unsubscribed dispatcher
*/
@@ -98,7 +98,7 @@ class VoiceBroadcast extends VolumeInterface {
this._dispatchers.get(n).add(dispatcher);
});
/**
* Emitted whenever a stream dispatcher subscribes to the broadcast
* Emitted whenever a stream dispatcher subscribes to the broadcast.
* @event VoiceBroadcast#subscribe
* @param {StreamDispatcher} dispatcher The subscribed dispatcher
*/
@@ -115,7 +115,7 @@ class VoiceBroadcast extends VolumeInterface {
}
/**
* Plays any audio stream across the broadcast
* Plays any audio stream across the broadcast.
* @param {ReadableStream} stream The audio stream to play
* @param {StreamOptions} [options] Options for playing the stream
* @returns {VoiceBroadcast}
@@ -169,21 +169,21 @@ class VoiceBroadcast extends VolumeInterface {
ffmpegArguments: ffmpegArguments.concat(['-ss', String(options.seek)]),
});
/**
* Emitted whenever an error occurs
* Emitted whenever an error occurs.
* @event VoiceBroadcast#error
* @param {Error} error the error that occurred
* @param {Error} error The error that occurred
*/
transcoder.once('error', e => {
if (this.listenerCount('error') > 0) this.emit('error', e);
/**
* Emitted whenever the VoiceBroadcast has any warnings
* Emitted whenever the VoiceBroadcast has any warnings.
* @event VoiceBroadcast#warn
* @param {string|Error} warning the warning that was raised
* @param {string|Error} warning The warning that was raised
*/
else this.emit('warn', e);
});
/**
* Emitted once the broadcast (the audio stream) ends
* Emitted once the broadcast (the audio stream) ends.
* @event VoiceBroadcast#end
*/
transcoder.once('end', () => this.killCurrentTranscoder());
@@ -197,7 +197,7 @@ class VoiceBroadcast extends VolumeInterface {
/**
* Plays a stream of 16-bit signed stereo PCM at 48KHz.
* @param {ReadableStream} stream The audio stream to play.
* @param {ReadableStream} stream The audio stream to play
* @param {StreamOptions} [options] Options for playing the stream
* @returns {VoiceBroadcast}
*/
@@ -227,7 +227,7 @@ class VoiceBroadcast extends VolumeInterface {
/**
* Play an arbitrary input that can be [handled by ffmpeg](https://ffmpeg.org/ffmpeg-protocols.html#Description)
* @param {string} input the arbitrary input
* @param {string} input The arbitrary input
* @param {StreamOptions} [options] Options for playing the stream
* @returns {VoiceBroadcast}
*/
@@ -239,7 +239,7 @@ class VoiceBroadcast extends VolumeInterface {
}
/**
* Pauses the entire broadcast - all dispatchers also pause
* Pauses the entire broadcast - all dispatchers also pause.
*/
pause() {
this.paused = true;
@@ -251,7 +251,7 @@ class VoiceBroadcast extends VolumeInterface {
}
/**
* Resumes the entire broadcast - all dispatchers also resume
* Resumes the entire broadcast - all dispatchers also resume.
*/
resume() {
this.paused = false;
@@ -351,7 +351,7 @@ class VoiceBroadcast extends VolumeInterface {
}
/**
* End the current broadcast, all subscribed dispatchers will also end
* End the current broadcast, all subscribed dispatchers will also end.
*/
destroy() {
this.end();

View File

@@ -83,18 +83,18 @@ class VoiceConnection extends EventEmitter {
this.player.on('debug', m => {
/**
* Debug info from the connection
* Debug info from the connection.
* @event VoiceConnection#debug
* @param {string} message the debug message
* @param {string} message The debug message
*/
this.emit('debug', `audio player - ${m}`);
});
this.player.on('error', e => {
/**
* Warning info from the connection
* Warning info from the connection.
* @event VoiceConnection#warn
* @param {string|Error} warning the warning
* @param {string|Error} warning The warning
*/
this.emit('warn', e);
});
@@ -126,8 +126,8 @@ class VoiceConnection extends EventEmitter {
}
/**
* Sets whether the voice connection should display as "speaking" or not
* @param {boolean} value whether or not to speak
* Sets whether the voice connection should display as "speaking" or not.
* @param {boolean} value Whether or not to speak
* @private
*/
setSpeaking(value) {
@@ -145,7 +145,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Sends a request to the main gateway to join a voice channel
* Sends a request to the main gateway to join a voice channel.
* @param {Object} [options] The options to provide
*/
sendVoiceStateUpdate(options = {}) {
@@ -163,7 +163,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Set the token and endpoint required to connect to the the voice servers
* Set the token and endpoint required to connect to the the voice servers.
* @param {string} token The voice token
* @param {string} endpoint The voice endpoint
* @returns {void}
@@ -195,7 +195,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Sets the Session ID for the connection
* Sets the Session ID for the connection.
* @param {string} sessionID The voice session ID
*/
setSessionID(sessionID) {
@@ -210,7 +210,7 @@ class VoiceConnection extends EventEmitter {
} else if (sessionID !== this.authentication.sessionID) {
this.authentication.sessionID = sessionID;
/**
* Emitted when a new session ID is received
* Emitted when a new session ID is received.
* @event VoiceConnection#newSession
* @private
*/
@@ -219,7 +219,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Checks whether the voice connection is authenticated
* Checks whether the voice connection is authenticated.
* @private
*/
checkAuthenticated() {
@@ -229,7 +229,7 @@ class VoiceConnection extends EventEmitter {
clearTimeout(this.connectTimeout);
this.status = Constants.VoiceStatus.CONNECTING;
/**
* Emitted when we successfully initiate a voice connection
* Emitted when we successfully initiate a voice connection.
* @event VoiceConnection#authenticated
*/
this.emit('authenticated');
@@ -238,7 +238,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Invoked when we fail to initiate a voice connection
* Invoked when we fail to initiate a voice connection.
* @param {string} reason The reason for failure
* @private
*/
@@ -247,7 +247,7 @@ class VoiceConnection extends EventEmitter {
this.status = Constants.VoiceStatus.DISCONNECTED;
if (this.status === Constants.VoiceStatus.AUTHENTICATING) {
/**
* Emitted when we fail to initiate a voice connection
* Emitted when we fail to initiate a voice connection.
* @event VoiceConnection#failed
* @param {Error} error The encountered error
*/
@@ -258,7 +258,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Move to a different voice channel in the same guild
* Move to a different voice channel in the same guild.
* @param {VoiceChannel} channel The channel to move to
* @private
*/
@@ -268,7 +268,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Attempts to authenticate to the voice server
* Attempts to authenticate to the voice server.
* @private
*/
authenticate() {
@@ -278,7 +278,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Attempts to reconnect to the voice server (typically after a region change)
* Attempts to reconnect to the voice server (typically after a region change).
* @param {string} token The voice token
* @param {string} endpoint The voice endpoint
* @private
@@ -289,7 +289,7 @@ class VoiceConnection extends EventEmitter {
this.status = Constants.VoiceStatus.RECONNECTING;
/**
* Emitted when the voice connection is reconnecting (typically after a region change)
* Emitted when the voice connection is reconnecting (typically after a region change).
* @event VoiceConnection#reconnecting
*/
this.emit('reconnecting');
@@ -308,14 +308,14 @@ class VoiceConnection extends EventEmitter {
this.cleanup();
this.status = Constants.VoiceStatus.DISCONNECTED;
/**
* Emitted when the voice connection disconnects
* Emitted when the voice connection disconnects.
* @event VoiceConnection#disconnect
*/
this.emit('disconnect');
}
/**
* Cleans up after disconnect
* Cleans up after disconnect.
* @private
*/
cleanup() {
@@ -335,7 +335,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Connect the voice connection
* Connect the voice connection.
* @private
*/
connect() {
@@ -360,7 +360,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Invoked when the voice websocket is ready
* Invoked when the voice websocket is ready.
* @param {Object} data The received data
* @private
*/
@@ -381,7 +381,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Invoked when a session description is received
* Invoked when a session description is received.
* @param {string} mode The encryption mode
* @param {string} secret The secret key
* @private
@@ -400,7 +400,7 @@ class VoiceConnection extends EventEmitter {
}
/**
* Invoked when a speaking event is received
* Invoked when a speaking event is received.
* @param {Object} data The received data
* @private
*/
@@ -414,7 +414,7 @@ class VoiceConnection extends EventEmitter {
}
}
/**
* Emitted whenever a user starts/stops speaking
* Emitted whenever a user starts/stops speaking.
* @event VoiceConnection#speaking
* @param {User} user The user that has started/stopped speaking
* @param {boolean} speaking Whether or not the user is speaking
@@ -500,8 +500,8 @@ class VoiceConnection extends EventEmitter {
}
/**
* Plays a voice broadcast
* @param {VoiceBroadcast} broadcast the broadcast to play
* Plays a voice broadcast.
* @param {VoiceBroadcast} broadcast The broadcast to play
* @returns {StreamDispatcher}
* @example
* // Play a broadcast

View File

@@ -4,7 +4,7 @@ const Constants = require('../../util/Constants');
const EventEmitter = require('events').EventEmitter;
/**
* Represents a UDP Client for a Voice Connection
* Represents a UDP client for a Voice Connection.
* @extends {EventEmitter}
* @private
*/
@@ -25,7 +25,7 @@ class VoiceConnectionUDPClient extends EventEmitter {
this.socket = null;
/**
* The address of the discord voice server
* The address of the Discord voice server
* @type {?string}
*/
this.discordAddress = null;
@@ -57,7 +57,7 @@ class VoiceConnectionUDPClient extends EventEmitter {
}
/**
* The port of the discord voice server
* The port of the Discord voice server
* @type {number}
* @readonly
*/
@@ -66,7 +66,7 @@ class VoiceConnectionUDPClient extends EventEmitter {
}
/**
* Tries to resolve the voice server endpoint to an address
* Tries to resolve the voice server endpoint to an address.
* @returns {Promise<string>}
*/
findEndpointAddress() {
@@ -83,7 +83,7 @@ class VoiceConnectionUDPClient extends EventEmitter {
}
/**
* Send a packet to the UDP client
* Send a packet to the UDP client.
* @param {Object} packet The packet to send
* @returns {Promise<Object>}
*/

View File

@@ -10,7 +10,7 @@ try {
}
/**
* Represents a Voice Connection's WebSocket
* Represents a Voice Connection's WebSocket.
* @extends {EventEmitter}
* @private
*/
@@ -18,6 +18,12 @@ class VoiceWebSocket extends EventEmitter {
constructor(voiceConnection) {
super();
/**
* The client of this voice WebSocket
* @type {Client}
*/
this.client = voiceConnection.voiceManager.client;
/**
* The Voice Connection that this WebSocket serves
* @type {VoiceConnection}
@@ -41,16 +47,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* The client of this voice websocket
* @type {Client}
* @readonly
*/
get client() {
return this.voiceConnection.voiceManager.client;
}
/**
* Resets the current WebSocket
* Resets the current WebSocket.
*/
reset() {
if (this.ws) {
@@ -86,7 +83,7 @@ class VoiceWebSocket extends EventEmitter {
/**
* Sends data to the WebSocket if it is open.
* @param {string} data the data to send to the WebSocket
* @param {string} data The data to send to the WebSocket
* @returns {Promise<string>}
*/
send(data) {
@@ -102,7 +99,7 @@ class VoiceWebSocket extends EventEmitter {
/**
* JSON.stringify's a packet and then sends it to the WebSocket Server.
* @param {Object} packet the packet to send
* @param {Object} packet The packet to send
* @returns {Promise<string>}
*/
sendPacket(packet) {
@@ -115,7 +112,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Called whenever the WebSocket opens
* Called whenever the WebSocket opens.
*/
onOpen() {
this.sendPacket({
@@ -132,8 +129,8 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Called whenever a message is received from the WebSocket
* @param {MessageEvent} event the message event that was received
* Called whenever a message is received from the WebSocket.
* @param {MessageEvent} event The message event that was received
* @returns {void}
*/
onMessage(event) {
@@ -145,7 +142,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Called whenever the connection to the WebSocket Server is lost
* Called whenever the connection to the WebSocket server is lost.
*/
onClose() {
if (!this.dead) this.client.setTimeout(this.connect.bind(this), this.attempts * 1000);
@@ -160,7 +157,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Called whenever a valid packet is received from the WebSocket
* Called whenever a valid packet is received from the WebSocket.
* @param {Object} packet The received packet
*/
onPacket(packet) {
@@ -168,7 +165,7 @@ class VoiceWebSocket extends EventEmitter {
case Constants.VoiceOPCodes.READY:
this.setHeartbeat(packet.d.heartbeat_interval);
/**
* Emitted once the voice websocket receives the ready packet
* Emitted once the voice WebSocket receives the ready packet.
* @param {Object} packet The received packet
* @event VoiceWebSocket#ready
*/
@@ -176,7 +173,7 @@ class VoiceWebSocket extends EventEmitter {
break;
case Constants.VoiceOPCodes.SESSION_DESCRIPTION:
/**
* Emitted once the Voice Websocket receives a description of this voice session
* Emitted once the Voice Websocket receives a description of this voice session.
* @param {string} encryptionMode The type of encryption being used
* @param {SecretKey} secretKey The secret key used for encryption
* @event VoiceWebSocket#sessionDescription
@@ -185,7 +182,7 @@ class VoiceWebSocket extends EventEmitter {
break;
case Constants.VoiceOPCodes.SPEAKING:
/**
* Emitted whenever a speaking packet is received
* Emitted whenever a speaking packet is received.
* @param {Object} data
* @event VoiceWebSocket#speaking
*/
@@ -193,7 +190,7 @@ class VoiceWebSocket extends EventEmitter {
break;
default:
/**
* Emitted when an unhandled packet is received
* Emitted when an unhandled packet is received.
* @param {Object} packet
* @event VoiceWebSocket#unknownPacket
*/
@@ -203,7 +200,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Sets an interval at which to send a heartbeat packet to the WebSocket
* Sets an interval at which to send a heartbeat packet to the WebSocket.
* @param {number} interval The interval at which to send a heartbeat packet
*/
setHeartbeat(interval) {
@@ -213,7 +210,7 @@ class VoiceWebSocket extends EventEmitter {
}
if (this.heartbeatInterval) {
/**
* Emitted whenver the voice websocket encounters a non-fatal error
* Emitted whenver the voice WebSocket encounters a non-fatal error.
* @param {string} warn The warning
* @event VoiceWebSocket#warn
*/
@@ -224,7 +221,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Clears a heartbeat interval, if one exists
* Clears a heartbeat interval, if one exists.
*/
clearHeartbeat() {
if (!this.heartbeatInterval) {
@@ -236,7 +233,7 @@ class VoiceWebSocket extends EventEmitter {
}
/**
* Sends a heartbeat packet
* Sends a heartbeat packet.
*/
sendHeartbeat() {
this.sendPacket({ op: Constants.VoiceOPCodes.HEARTBEAT, d: null }).catch(() => {

View File

@@ -53,7 +53,7 @@ class StreamDispatcher extends VolumeInterface {
/**
* How many passes the dispatcher should take when sending packets to reduce packet loss. Values over 5
* aren't recommended, as it means you are using 5x more bandwidth. You _can_ edit this at runtime.
* aren't recommended, as it means you are using 5x more bandwidth. You _can_ edit this at runtime
* @type {number}
* @readonly
*/
@@ -100,7 +100,7 @@ class StreamDispatcher extends VolumeInterface {
/**
* Stops the current stream permanently and emits an `end` event.
* @param {string} [reason='user'] An optional reason for stopping the dispatcher.
* @param {string} [reason='user'] An optional reason for stopping the dispatcher
*/
end(reason = 'user') {
this.destroy('end', reason);
@@ -110,7 +110,7 @@ class StreamDispatcher extends VolumeInterface {
if (this.speaking === value) return;
this.speaking = value;
/**
* Emitted when the dispatcher starts/stops speaking
* Emitted when the dispatcher starts/stops speaking.
* @event StreamDispatcher#speaking
* @param {boolean} value Whether or not the dispatcher is speaking
*/
@@ -126,7 +126,7 @@ class StreamDispatcher extends VolumeInterface {
sendPacket(packet) {
let repeats = this.passes;
/**
* Emitted whenever the dispatcher has debug information
* Emitted whenever the dispatcher has debug information.
* @event StreamDispatcher#debug
* @param {string} info the debug info
*/
@@ -260,7 +260,7 @@ class StreamDispatcher extends VolumeInterface {
if (!data.startTime) {
/**
* Emitted once the dispatcher starts streaming
* Emitted once the dispatcher starts streaming.
* @event StreamDispatcher#start
*/
this.emit('start');
@@ -281,7 +281,7 @@ class StreamDispatcher extends VolumeInterface {
this.setSpeaking(false);
this.emit(type, reason);
/**
* Emitted once the dispatcher ends
* Emitted once the dispatcher ends.
* @param {string} [reason] the reason the dispatcher ended
* @event StreamDispatcher#end
*/
@@ -291,9 +291,9 @@ class StreamDispatcher extends VolumeInterface {
startStreaming() {
if (!this.stream) {
/**
* Emitted if the dispatcher encounters an error
* Emitted if the dispatcher encounters an error.
* @event StreamDispatcher#error
* @param {string} error the error message
* @param {string} error The error message
*/
this.emit('error', 'No stream');
return;

View File

@@ -13,7 +13,7 @@ const ffmpegArguments = [
];
/**
* An Audio Player for a Voice Connection
* An Audio Player for a Voice Connection.
* @private
* @extends {EventEmitter}
*/

View File

@@ -21,7 +21,7 @@ class VoiceReceiver extends EventEmitter {
super();
/*
Need a queue because we don't get the ssrc of the user speaking until after the first few packets,
so we queue up unknown SSRCs until they become known, then empty the queue.
so we queue up unknown SSRCs until they become known, then empty the queue
*/
this.queues = new Map();
this.pcmStreams = new Map();
@@ -29,7 +29,7 @@ class VoiceReceiver extends EventEmitter {
this.opusEncoders = new Map();
/**
* Whether or not this receiver has been destroyed.
* Whether or not this receiver has been destroyed
* @type {boolean}
*/
this.destroyed = false;
@@ -91,7 +91,7 @@ class VoiceReceiver extends EventEmitter {
}
/**
* Invoked when a user stops speaking
* Invoked when a user stops speaking.
* @param {User} user The user that stopped speaking
* @private
*/
@@ -153,7 +153,7 @@ class VoiceReceiver extends EventEmitter {
* @event VoiceReceiver#warn
* @param {string} reason The reason for the warning. If it happened because the voice packet could not be
* decrypted, this would be `decrypt`. If it happened because the voice packet could not be decoded into
* PCM, this would be `decode`.
* PCM, this would be `decode`
* @param {string} message The warning message
*/
this.emit('warn', 'decrypt', 'Failed to decrypt voice packet');

View File

@@ -1,5 +1,5 @@
/**
* Represents a Secret Key used in encryption over voice
* Represents a Secret Key used in encryption over voice.
* @private
*/
class SecretKey {

View File

@@ -10,51 +10,6 @@ class VolumeInterface extends EventEmitter {
this.setVolume(volume || 1);
}
applyVolume(buffer, volume) {
volume = volume || this._volume;
if (volume === 1) return buffer;
const out = new Buffer(buffer.length);
for (let i = 0; i < buffer.length; i += 2) {
if (i >= buffer.length - 1) break;
const uint = Math.min(32767, Math.max(-32767, Math.floor(volume * buffer.readInt16LE(i))));
out.writeInt16LE(uint, i);
}
return out;
}
/**
* Sets the volume relative to the input stream - i.e. 1 is normal, 0.5 is half, 2 is double.
* @param {number} volume The volume that you want to set
*/
setVolume(volume) {
/**
* Emitted when the volume of this interface changes
* @event VolumeInterface#volumeChange
* @param {number} oldVolume The old volume of this interface
* @param {number} newVolume The new volume of this interface
*/
this.emit('volumeChange', this._volume, volume);
this._volume = volume;
}
/**
* Set the volume in decibels
* @param {number} db The decibels
*/
setVolumeDecibels(db) {
this.setVolume(Math.pow(10, db / 20));
}
/**
* Set the volume so that a perceived value of 0.5 is half the perceived volume etc.
* @param {number} value The value for the volume
*/
setVolumeLogarithmic(value) {
this.setVolume(Math.pow(value, 1.660964));
}
/**
* The current volume of the broadcast
* @readonly
@@ -81,6 +36,51 @@ class VolumeInterface extends EventEmitter {
get volumeLogarithmic() {
return Math.pow(this._volume, 1 / 1.660964);
}
applyVolume(buffer, volume) {
volume = volume || this._volume;
if (volume === 1) return buffer;
const out = new Buffer(buffer.length);
for (let i = 0; i < buffer.length; i += 2) {
if (i >= buffer.length - 1) break;
const uint = Math.min(32767, Math.max(-32767, Math.floor(volume * buffer.readInt16LE(i))));
out.writeInt16LE(uint, i);
}
return out;
}
/**
* Sets the volume relative to the input stream - i.e. 1 is normal, 0.5 is half, 2 is double.
* @param {number} volume The volume that you want to set
*/
setVolume(volume) {
/**
* Emitted when the volume of this interface changes.
* @event VolumeInterface#volumeChange
* @param {number} oldVolume The old volume of this interface
* @param {number} newVolume The new volume of this interface
*/
this.emit('volumeChange', this._volume, volume);
this._volume = volume;
}
/**
* Set the volume in decibels.
* @param {number} db The decibels
*/
setVolumeDecibels(db) {
this.setVolume(Math.pow(10, db / 20));
}
/**
* Set the volume so that a perceived value of 0.5 is half the perceived volume etc.
* @param {number} value The value for the volume
*/
setVolumeLogarithmic(value) {
this.setVolume(Math.pow(value, 1.660964));
}
}
module.exports = VolumeInterface;

View File

@@ -23,13 +23,13 @@ const WebSocket = (function findWebSocket() {
}());
/**
* Abstracts a WebSocket connection with decoding/encoding for the discord gateway
* Abstracts a WebSocket connection with decoding/encoding for the Discord gateway.
* @private
*/
class WebSocketConnection extends EventEmitter {
/**
* @param {WebSocketManager} manager the WebSocket manager
* @param {string} gateway Websocket gateway to connect to
* @param {WebSocketManager} manager The WebSocket manager
* @param {string} gateway WebSocket gateway to connect to
*/
constructor(manager, gateway) {
super();
@@ -38,36 +38,43 @@ class WebSocketConnection extends EventEmitter {
* @type {WebSocketManager}
*/
this.manager = manager;
/**
* Client this belongs to
* The client this belongs to
* @type {Client}
*/
this.client = manager.client;
/**
* WebSocket connection itself
* The WebSocket connection itself
* @type {WebSocket}
*/
this.ws = null;
/**
* Current sequence of the WebSocket
* The current sequence of the WebSocket
* @type {number}
*/
this.sequence = -1;
/**
* Current status of the client
* The current status of the client
* @type {number}
*/
this.status = Constants.Status.IDLE;
/**
* Packet Manager of the connection
* The Packet Manager of the connection
* @type {WebSocketPacketManager}
*/
this.packetManager = new PacketManager(this);
/**
* Last time a ping was sent (a timestamp)
* The last time a ping was sent (a timestamp)
* @type {number}
*/
this.lastPingTimestamp = 0;
/**
* Contains the rate limit queue and metadata
* @type {Object}
@@ -78,13 +85,15 @@ class WebSocketConnection extends EventEmitter {
resetTime: -1,
};
this.connect(gateway);
/**
* Events that are disabled (will not be processed)
* @type {Object}
*/
this.disabledEvents = {};
/**
* Sequence on WebSocket close
* The sequence on WebSocket close
* @type {number}
*/
this.closeSequence = 0;
@@ -92,7 +101,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Causes the client to be marked as ready and emits the ready event
* Causes the client to be marked as ready and emits the ready event.
* @returns {void}
*/
triggerReady() {
@@ -106,7 +115,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Checks whether the client is ready to be marked as ready
* Checks whether the client is ready to be marked as ready.
* @returns {void}
*/
checkIfReady() {
@@ -132,7 +141,7 @@ class WebSocketConnection extends EventEmitter {
// Util
/**
* Emits a debug message
* Emits a debug message.
* @param {string} message Debug message
* @returns {void}
*/
@@ -142,7 +151,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Attempts to serialise data from the WebSocket
* Attempts to serialise data from the WebSocket.
* @param {string|Object} data Data to unpack
* @returns {Object}
*/
@@ -157,7 +166,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Packs an object ready to be sent
* Packs an object ready to be sent.
* @param {Object} data Data to pack
* @returns {string|Buffer}
*/
@@ -166,7 +175,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Processes the current WebSocket queue
* Processes the current WebSocket queue.
*/
processQueue() {
if (this.ratelimit.remaining === 0) return;
@@ -186,7 +195,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Sends data, bypassing the queue
* Sends data, bypassing the queue.
* @param {Object} data Packet to send
* @returns {void}
*/
@@ -199,7 +208,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Adds data to the queue to be sent
* Adds data to the queue to be sent.
* @param {Object} data Packet to send
* @returns {void}
*/
@@ -213,7 +222,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Creates a connection to a gateway
* Creates a connection to a gateway.
* @param {string} gateway Gateway to connect to
* @param {number} [after=0] How long to wait before connecting
* @param {boolean} [force=false] Whether or not to force a new connection even if one already exists
@@ -241,7 +250,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Destroys the connection
* Destroys the connection.
* @returns {boolean}
*/
destroy() {
@@ -259,7 +268,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Called whenever a message is received
* Called whenever a message is received.
* @param {Event} event Event received
* @returns {boolean}
*/
@@ -274,7 +283,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Sets the current sequence of the connection
* Sets the current sequence of the connection.
* @param {number} s New sequence
*/
setSequence(s) {
@@ -282,8 +291,8 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Called whenever a packet is received
* @param {Object} packet received packet
* Called whenever a packet is received.
* @param {Object} packet Received packet
* @returns {boolean}
*/
onPacket(packet) {
@@ -311,7 +320,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Called whenever a connection is opened to the gateway
* Called whenever a connection is opened to the gateway.
* @param {Event} event Received open event
*/
onOpen(event) {
@@ -321,7 +330,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Causes a reconnection to the gateway
* Causes a reconnection to the gateway.
*/
reconnect() {
this.debug('Attemping to reconnect in 5500ms...');
@@ -330,7 +339,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Called whenever an error occurs with the WebSocket
* Called whenever an error occurs with the WebSocket.
* @param {Error} error Error that occurred
*/
onError(error) {
@@ -343,7 +352,7 @@ class WebSocketConnection extends EventEmitter {
*/
/**
* Called whenever a connection to the gateway is closed
* Called whenever a connection to the gateway is closed.
* @param {CloseEvent} event Close event that was received
*/
onClose(event) {
@@ -363,7 +372,7 @@ class WebSocketConnection extends EventEmitter {
// Heartbeat
/**
* Acknowledges a heartbeat
* Acknowledges a heartbeat.
*/
ackHeartbeat() {
this.debug(`Heartbeat acknowledged, latency of ${Date.now() - this.lastPingTimestamp}ms`);
@@ -372,8 +381,8 @@ class WebSocketConnection extends EventEmitter {
/**
* Sends a heartbeat or sets an interval for sending heartbeats.
* @param {number} [time] If -1, clears the interval, any other number sets an interval.
* If no value is given, a heartbeat will be sent instantly.
* @param {number} [time] If -1, clears the interval, any other number sets an interval
* If no value is given, a heartbeat will be sent instantly
*/
heartbeat(time) {
if (!isNaN(time)) {
@@ -397,7 +406,7 @@ class WebSocketConnection extends EventEmitter {
// Identification
/**
* Identifies the client on a connection
* Identifies the client on a connection.
* @param {number} [after] How long to wait before identifying
* @returns {void}
*/
@@ -407,7 +416,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Identifies as a new connection on the gateway
* Identifies as a new connection on the gateway.
* @returns {void}
*/
identifyNew() {
@@ -428,7 +437,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Resumes a session on the gateway
* Resumes a session on the gateway.
* @returns {void}
*/
identifyResume() {
@@ -452,7 +461,7 @@ class WebSocketConnection extends EventEmitter {
}
/**
* Encoding the WebSocket connections will use
* Encoding the WebSocket connections will use.
* @type {string}
*/
WebSocketConnection.ENCODING = erlpack ? 'etf' : 'json';

View File

@@ -3,20 +3,20 @@ const Constants = require('../../util/Constants');
const WebSocketConnection = require('./WebSocketConnection');
/**
* WebSocket Manager of the Client
* WebSocket Manager of the client
* @private
*/
class WebSocketManager extends EventEmitter {
constructor(client) {
super();
/**
* Client that instantiated this WebSocketManager
* The client that instantiated this WebSocketManager
* @type {Client}
*/
this.client = client;
/**
* WebSocket connection of this manager
* The WebSocket connection of this manager
* @type {?WebSocketConnection}
*/
this.connection = null;
@@ -32,7 +32,7 @@ class WebSocketManager extends EventEmitter {
}
/**
* Emits a debug event
* Emits a debug event.
* @param {string} message Debug message
* @returns {void}
*/
@@ -41,7 +41,7 @@ class WebSocketManager extends EventEmitter {
}
/**
* Destroy the client
* Destroy the client.
* @returns {void} Whether or not destruction was successful
*/
destroy() {
@@ -53,7 +53,7 @@ class WebSocketManager extends EventEmitter {
}
/**
* Send a packet on the available WebSocket
* Send a packet on the available WebSocket.
* @param {Object} packet Packet to send
* @returns {void}
*/
@@ -66,7 +66,7 @@ class WebSocketManager extends EventEmitter {
}
/**
* Connects the client to a gateway
* Connects the client to a gateway.
* @param {string} gateway Gateway to connect to
* @returns {boolean}
*/

View File

@@ -24,7 +24,7 @@ class GuildMembersChunkHandler extends AbstractHandler {
}
/**
* Emitted whenever a chunk of guild members is received (all members come from the same guild)
* Emitted whenever a chunk of guild members is received (all members come from the same guild).
* @event Client#guildMembersChunk
* @param {Collection<Snowflake, GuildMember>} members The members in the chunk
* @param {Guild} guild The guild related to the member chunk

View File

@@ -11,7 +11,7 @@ class MessageCreateHandler extends AbstractHandler {
}
/**
* Emitted whenever a message is created
* Emitted whenever a message is created.
* @event Client#message
* @param {Message} message The created message
*/

View File

@@ -11,7 +11,7 @@ class MessageDeleteHandler extends AbstractHandler {
}
/**
* Emitted whenever a message is deleted
* Emitted whenever a message is deleted.
* @event Client#messageDelete
* @param {Message} message The deleted message
*/

View File

@@ -9,7 +9,7 @@ class MessageDeleteBulkHandler extends AbstractHandler {
}
/**
* Emitted whenever messages are deleted in bulk
* Emitted whenever messages are deleted in bulk.
* @event Client#messageDeleteBulk
* @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their ID
*/

View File

@@ -68,7 +68,7 @@ class PresenceUpdateHandler extends AbstractHandler {
*/
/**
* Emitted whenever a member becomes available in a large guild
* Emitted whenever a member becomes available in a large guild.
* @event Client#guildMemberAvailable
* @param {GuildMember} member The member that became available
*/

View File

@@ -20,9 +20,9 @@ class ResumedHandler extends AbstractHandler {
}
/**
* Emitted whenever a websocket resumes
* Emitted whenever a WebSocket resumes.
* @event Client#resume
* @param {number} replayed Number of events that were replayed
* @param {number} replayed The number of events that were replayed
*/
module.exports = ResumedHandler;

View File

@@ -52,14 +52,14 @@ function tooLate(channel, user) {
}
/**
* Emitted whenever a user starts typing in a channel
* Emitted whenever a user starts typing in a channel.
* @event Client#typingStart
* @param {Channel} channel The channel the user started typing in
* @param {User} user The user that started typing
*/
/**
* Emitted whenever a user stops typing in a channel
* Emitted whenever a user stops typing in a channel.
* @event Client#typingStop
* @param {Channel} channel The channel the user stopped typing in
* @param {User} user The user that stopped typing

View File

@@ -10,7 +10,7 @@ class UserSettingsUpdateHandler extends AbstractHandler {
}
/**
* Emitted when the client user's settings update
* Emitted when the client user's settings update.
* @event Client#clientUserSettingsUpdate
* @param {ClientUserSettings} clientUserSettings The new client user settings
*/

View File

@@ -65,8 +65,8 @@ class Shard {
}
/**
* Fetches a Client property value of the shard.
* @param {string} prop Name of the Client property to get, using periods for nesting
* Fetches a client property value of the shard.
* @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<*>}
* @example
* shard.fetchClientValue('guilds.size').then(count => {
@@ -97,7 +97,7 @@ class Shard {
}
/**
* Evaluates a script on the shard, in the context of the Client.
* Evaluates a script on the shard, in the context of the client.
* @param {string} script JavaScript to run on the shard
* @returns {Promise<*>} Result of the script execution
*/
@@ -125,7 +125,7 @@ class Shard {
}
/**
* Handles an IPC message
* Handles an IPC message.
* @param {*} message Message received
* @private
*/
@@ -151,7 +151,7 @@ class Shard {
}
/**
* Emitted upon recieving a message from a shard
* Emitted upon recieving a message from a shard.
* @event ShardingManager#message
* @param {Shard} shard Shard that sent the message
* @param {*} message Message that was received

View File

@@ -1,11 +1,11 @@
const Util = require('../util/Util');
/**
* Helper class for sharded clients spawned as a child process, such as from a ShardingManager
* Helper class for sharded clients spawned as a child process, such as from a ShardingManager.
*/
class ShardClientUtil {
/**
* @param {Client} client Client of the current shard
* @param {Client} client The client of the current shard
*/
constructor(client) {
this.client = client;
@@ -31,7 +31,7 @@ class ShardClientUtil {
}
/**
* Sends a message to the master process
* Sends a message to the master process.
* @param {*} message Message to send
* @returns {Promise<void>}
*/
@@ -45,8 +45,8 @@ class ShardClientUtil {
}
/**
* Fetches a Client property value of each shard.
* @param {string} prop Name of the Client property to get, using periods for nesting
* Fetches a client property value of each shard.
* @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<Array>}
* @example
* client.shard.fetchClientValues('guilds.size').then(results => {
@@ -91,7 +91,7 @@ class ShardClientUtil {
}
/**
* Handles an IPC message
* Handles an IPC message.
* @param {*} message Message received
* @private
*/
@@ -112,7 +112,7 @@ class ShardClientUtil {
}
/**
* Sends a message to the master process, emitting an error from the client upon failure
* Sends a message to the master process, emitting an error from the client upon failure.
* @param {string} type Type of response to send
* @param {*} message Message to send
* @private
@@ -125,8 +125,8 @@ class ShardClientUtil {
}
/**
* Creates/gets the singleton of this class
* @param {Client} client Client to use
* Creates/gets the singleton of this class.
* @param {Client} client The client to use
* @returns {ShardClientUtil}
*/
static singleton(client) {

View File

@@ -6,7 +6,7 @@ const Collection = require('../util/Collection');
const Util = require('../util/Util');
/**
* This is a utility class that can be used to help you spawn shards of your Client. Each shard is completely separate
* This is a utility class that can be used to help you spawn shards of your client. Each shard is completely separate
* from the other. The Shard Manager takes a path to a file and spawns it under the specified amount of shards safely.
* If you do not select an amount of shards, the manager will automatically decide the best amount.
* @extends {EventEmitter}
@@ -61,7 +61,7 @@ class ShardingManager extends EventEmitter {
this.respawn = options.respawn;
/**
* An array of arguments to pass to shards.
* An array of arguments to pass to shards
* @type {string[]}
*/
this.shardArgs = options.shardArgs;
@@ -81,14 +81,14 @@ class ShardingManager extends EventEmitter {
/**
* Spawns a single shard.
* @param {number} id The ID of the shard to spawn. **This is usually not necessary.**
* @param {number} id The ID of the shard to spawn. **This is usually not necessary**
* @returns {Promise<Shard>}
*/
createShard(id = this.shards.size) {
const shard = new Shard(this, id, this.shardArgs);
this.shards.set(id, shard);
/**
* Emitted upon launching a shard
* Emitted upon launching a shard.
* @event ShardingManager#launch
* @param {Shard} shard Shard that was launched
*/
@@ -172,8 +172,8 @@ class ShardingManager extends EventEmitter {
}
/**
* Fetches a Client property value of each shard.
* @param {string} prop Name of the Client property to get, using periods for nesting
* Fetches a client property value of each shard.
* @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<Array>}
* @example
* manager.fetchClientValues('guilds.size').then(results => {

View File

@@ -1,7 +1,7 @@
const Snowflake = require('../util/Snowflake');
/**
* Represents any channel on Discord
* Represents any channel on Discord.
*/
class Channel {
constructor(client, data) {
@@ -53,13 +53,13 @@ class Channel {
}
/**
* Deletes the channel
* Deletes the channel.
* @returns {Promise<Channel>}
* @example
* // delete the channel
* // Delete the channel
* channel.delete()
* .then() // success
* .catch(console.error); // log error
* .then() // Success
* .catch(console.error); // Log error
*/
delete() {
return this.client.rest.methods.deleteChannel(this);

View File

@@ -4,7 +4,7 @@ const ClientUserSettings = require('./ClientUserSettings');
const Constants = require('../util/Constants');
/**
* Represents the logged in client's Discord user
* Represents the logged in client's Discord user.
* @extends {User}
*/
class ClientUser extends User {
@@ -26,28 +26,28 @@ class ClientUser extends User {
this._typing = new Map();
/**
* A Collection of friends for the logged in user.
* A Collection of friends for the logged in user
* <warn>This is only filled when using a user account.</warn>
* @type {Collection<Snowflake, User>}
*/
this.friends = new Collection();
/**
* A Collection of blocked users for the logged in user.
* A Collection of blocked users for the logged in user
* <warn>This is only filled when using a user account.</warn>
* @type {Collection<Snowflake, User>}
*/
this.blocked = new Collection();
/**
* A Collection of notes for the logged in user.
* A Collection of notes for the logged in user
* <warn>This is only filled when using a user account.</warn>
* @type {Collection<Snowflake, string>}
*/
this.notes = new Collection();
/**
* If the user has discord premium (nitro)
* If the user has Discord premium (nitro)
* <warn>This is only filled when using a user account.</warn>
* @type {?boolean}
*/
@@ -61,7 +61,7 @@ class ClientUser extends User {
this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
/**
* If the user has ever used a mobile device on discord
* If the user has ever used a mobile device on Discord
* <warn>This is only filled when using a user account.</warn>
* @type {?boolean}
*/
@@ -69,7 +69,7 @@ class ClientUser extends User {
/**
* Various settings for this user
* <warn>This is only filled when using a user account</warn>
* <warn>This is only filled when using a user account.</warn>
* @type {?ClientUserSettings}
*/
if (data.user_settings) this.settings = new ClientUserSettings(this, data.user_settings);
@@ -80,14 +80,14 @@ class ClientUser extends User {
}
/**
* Set the username of the logged in Client.
* Set the username of the logged in client.
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
* every hour. Use this sparingly!</info>
* @param {string} username The new username
* @param {string} [password] Current password (only for user accounts)
* @returns {Promise<ClientUser>}
* @example
* // set username
* // Set username
* client.user.setUsername('discordjs')
* .then(user => console.log(`My new username is ${user.username}`))
* .catch(console.error);
@@ -103,7 +103,7 @@ class ClientUser extends User {
* @param {string} password Current password
* @returns {Promise<ClientUser>}
* @example
* // set email
* // Set email
* client.user.setEmail('bob@gmail.com', 'some amazing password 123')
* .then(user => console.log(`My new email is ${user.email}`))
* .catch(console.error);
@@ -119,7 +119,7 @@ class ClientUser extends User {
* @param {string} oldPassword Current password
* @returns {Promise<ClientUser>}
* @example
* // set password
* // Set password
* client.user.setPassword('some new amazing password 456', 'some amazing password 123')
* .then(user => console.log('New password set!'))
* .catch(console.error);
@@ -129,11 +129,11 @@ class ClientUser extends User {
}
/**
* Set the avatar of the logged in Client.
* Set the avatar of the logged in client.
* @param {BufferResolvable|Base64Resolvable} avatar The new avatar
* @returns {Promise<ClientUser>}
* @example
* // set avatar
* // Set avatar
* client.user.setAvatar('./avatar.png')
* .then(user => console.log(`New avatar set!`))
* .catch(console.error);
@@ -149,7 +149,7 @@ class ClientUser extends User {
}
/**
* Data resembling a raw Discord presence
* Data resembling a raw Discord presence.
* @typedef {Object} PresenceData
* @property {PresenceStatus} [status] Status of the user
* @property {boolean} [afk] Whether the user is AFK
@@ -257,7 +257,7 @@ class ClientUser extends User {
}
/**
* Fetches messages that mentioned the client's user
* Fetches messages that mentioned the client's user.
* @param {Object} [options] Options for the fetch
* @param {number} [options.limit=25] Maximum number of mentions to retrieve
* @param {boolean} [options.roles=true] Whether to include role mentions
@@ -270,10 +270,10 @@ class ClientUser extends User {
}
/**
* Send a friend request
* Send a friend request.
* <warn>This is only available when using a user account.</warn>
* @param {UserResolvable} user The user to send the friend request to.
* @returns {Promise<User>} The user the friend request was sent to.
* @param {UserResolvable} user The user to send the friend request to
* @returns {Promise<User>} The user the friend request was sent to
*/
addFriend(user) {
user = this.client.resolver.resolveUser(user);
@@ -281,7 +281,7 @@ class ClientUser extends User {
}
/**
* Remove a friend
* Remove a friend.
* <warn>This is only available when using a user account.</warn>
* @param {UserResolvable} user The user to remove from your friends
* @returns {Promise<User>} The user that was removed
@@ -292,7 +292,7 @@ class ClientUser extends User {
}
/**
* Creates a guild
* Creates a guild.
* <warn>This is only available when using a user account.</warn>
* @param {string} name The name of the guild
* @param {string} region The region for the server
@@ -311,17 +311,17 @@ class ClientUser extends User {
}
/**
* An object containing either a user or access token, and an optional nickname
* An object containing either a user or access token, and an optional nickname.
* @typedef {Object} GroupDMRecipientOptions
* @property {UserResolvable|Snowflake} [user] User to add to the group DM
* @property {UserResolvable|Snowflake} [user] User to add to the Group DM
* (only available if a user is creating the DM)
* @property {string} [accessToken] Access token to use to add a user to the group DM
* @property {string} [accessToken] Access token to use to add a user to the Group DM
* (only available if a bot is creating the DM)
* @property {string} [nick] Permanent nickname (only available if a bot is creating the DM)
*/
/**
* Creates a group DM
* Creates a Group DM.
* @param {GroupDMRecipientOptions[]} recipients The recipients
* @returns {Promise<GroupDMChannel>}
*/
@@ -334,7 +334,7 @@ class ClientUser extends User {
}
/**
* Accepts an invite to join a guild
* Accepts an invite to join a guild.
* <warn>This is only available when using a user account.</warn>
* @param {Invite|string} invite Invite or code to accept
* @returns {Promise<Guild>} Joined guild

View File

@@ -2,7 +2,7 @@ const Constants = require('../util/Constants');
const Util = require('../util/Util');
/**
* A wrapper around the ClientUser's settings
* A wrapper around the ClientUser's settings.
*/
class ClientUserSettings {
constructor(user, data) {
@@ -11,7 +11,7 @@ class ClientUserSettings {
}
/**
* Patch the data contained in this class with new partial data
* Patch the data contained in this class with new partial data.
* @param {Object} data Data to patch this with
*/
patch(data) {
@@ -27,7 +27,7 @@ class ClientUserSettings {
}
/**
* Update a specific property of of user settings
* Update a specific property of of user settings.
* @param {string} name Name of property
* @param {value} value Value to patch
* @returns {Promise<Object>}
@@ -37,7 +37,7 @@ class ClientUserSettings {
}
/**
* @param {Guild} guild Guild to move
* @param {Guild} guild The guild to move
* @param {number} position Absolute or relative position
* @param {boolean} [relative=false] Whether to position relatively or absolutely
* @returns {Promise<Guild>}
@@ -49,8 +49,8 @@ class ClientUserSettings {
}
/**
* Add a guild to the list of restricted guilds
* @param {Guild} guild Guild to add
* Add a guild to the list of restricted guilds.
* @param {Guild} guild The guild to add
* @returns {Promise<Guild>}
*/
addRestrictedGuild(guild) {
@@ -61,8 +61,8 @@ class ClientUserSettings {
}
/**
* Remove a guild from the list of restricted guilds
* @param {Guild} guild Guild to remove
* Remove a guild from the list of restricted guilds.
* @param {Guild} guild The guild to remove
* @returns {Promise<Guild>}
*/
removeRestrictedGuild(guild) {

View File

@@ -3,12 +3,12 @@ const Collection = require('../util/Collection');
const Snowflake = require('../util/Snowflake');
/**
* Represents a custom emoji
* Represents a custom emoji.
*/
class Emoji {
constructor(guild, data) {
/**
* The Client that instantiated this object
* The client that instantiated this object
* @name Emoji#client
* @type {Client}
* @readonly
@@ -71,7 +71,7 @@ class Emoji {
}
/**
* A collection of roles this emoji is active for (empty if all), mapped by role ID.
* A collection of roles this emoji is active for (empty if all), mapped by role ID
* @type {Collection<Snowflake, Role>}
* @readonly
*/
@@ -103,18 +103,18 @@ class Emoji {
}
/**
* Data for editing an emoji
* Data for editing an emoji.
* @typedef {Object} EmojiEditData
* @property {string} [name] The name of the emoji
* @property {Collection<Snowflake, Role>|Array<Snowflake|Role>} [roles] Roles to restrict emoji to
*/
/**
* Edits the emoji
* Edits the emoji.
* @param {EmojiEditData} data The new data for the emoji
* @returns {Promise<Emoji>}
* @example
* // edit a emoji
* // Edit a emoji
* emoji.edit({name: 'newemoji'})
* .then(e => console.log(`Edited emoji ${e}`))
* .catch(console.error);
@@ -127,7 +127,7 @@ class Emoji {
* When concatenated with a string, this automatically returns the emoji mention rather than the object.
* @returns {string}
* @example
* // send an emoji:
* // Send an emoji:
* const emoji = guild.emojis.first();
* msg.reply(`Hello! ${emoji}`);
*/
@@ -136,9 +136,9 @@ class Emoji {
}
/**
* Whether this emoji is the same as another one
* @param {Emoji|Object} other the emoji to compare it to
* @returns {boolean} whether the emoji is equal to the given emoji or not
* Whether this emoji is the same as another one.
* @param {Emoji|Object} other The emoji to compare it to
* @returns {boolean} Whether the emoji is equal to the given emoji or not
*/
equals(other) {
if (other instanceof Emoji) {

View File

@@ -25,7 +25,7 @@ const Collection = require('../util/Collection');
*/
/**
* Represents a Group DM on Discord
* Represents a Group DM on Discord.
* @extends {Channel}
* @implements {TextBasedChannel}
*/
@@ -41,7 +41,7 @@ class GroupDMChannel extends Channel {
super.setup(data);
/**
* The name of this Group DM, can be null if one isn't set.
* The name of this Group DM, can be null if one isn't set
* @type {string}
*/
this.name = data.name;
@@ -53,19 +53,19 @@ class GroupDMChannel extends Channel {
this.icon = data.icon;
/**
* The user ID of this Group DM's owner.
* The user ID of this Group DM's owner
* @type {string}
*/
this.ownerID = data.owner_id;
/**
* If the dm is managed by an application
* If the DM is managed by an application
* @type {boolean}
*/
this.managed = data.managed;
/**
* Application ID of the application that made this group dm, if applicable
* Application ID of the application that made this Group DM, if applicable
* @type {?string}
*/
this.applicationID = data.application_id;
@@ -78,7 +78,7 @@ class GroupDMChannel extends Channel {
if (!this.recipients) {
/**
* A collection of the recipients of this DM, mapped by their ID.
* A collection of the recipients of this DM, mapped by their ID
* @type {Collection<Snowflake, User>}
*/
this.recipients = new Collection();
@@ -95,7 +95,7 @@ class GroupDMChannel extends Channel {
}
/**
* The owner of this Group DM.
* The owner of this Group DM
* @type {User}
* @readonly
*/
@@ -125,9 +125,9 @@ class GroupDMChannel extends Channel {
}
/**
* Add a user to the dm
* Add a user to the DM
* @param {UserResolvable|string} accessTokenOrID Access token or user resolvable
* @param {string} [nick] Permanent nickname to give the user (only available if a bot is creating the dm)
* @param {string} [nick] Permanent nickname to give the user (only available if a bot is creating the DM)
*/
addUser(accessTokenOrID, nick) {
@@ -142,10 +142,10 @@ class GroupDMChannel extends Channel {
* When concatenated with a string, this automatically concatenates the channel's name instead of the Channel object.
* @returns {string}
* @example
* // logs: Hello from My Group DM!
* // Logs: Hello from My Group DM!
* console.log(`Hello from ${channel}!`);
* @example
* // logs: Hello from My Group DM!
* // Logs: Hello from My Group DM!
* console.log(`Hello from ' + channel + '!');
*/
toString() {
@@ -170,7 +170,7 @@ class GroupDMChannel extends Channel {
get typingCount() {}
createCollector() {}
awaitMessages() {}
// Doesn't work on group DMs; bulkDelete() {}
// Doesn't work on Group DMs; bulkDelete() {}
acknowledge() {}
_cacheMessage() {}
}

View File

@@ -17,7 +17,7 @@ const Snowflake = require('../util/Snowflake');
class Guild {
constructor(client, data) {
/**
* The Client that created the instance of the the Guild.
* The client that created the instance of the the guild
* @name Guild#client
* @type {Client}
* @readonly
@@ -25,19 +25,19 @@ class Guild {
Object.defineProperty(this, 'client', { value: client });
/**
* A collection of members that are in this guild. The key is the member's ID, the value is the member.
* A collection of members that are in this guild. The key is the member's ID, the value is the member
* @type {Collection<Snowflake, GuildMember>}
*/
this.members = new Collection();
/**
* A collection of channels that are in this guild. The key is the channel's ID, the value is the channel.
* A collection of channels that are in this guild. The key is the channel's ID, the value is the channel
* @type {Collection<Snowflake, GuildChannel>}
*/
this.channels = new Collection();
/**
* A collection of roles that are in this guild. The key is the role's ID, the value is the role.
* A collection of roles that are in this guild. The key is the role's ID, the value is the role
* @type {Collection<Snowflake, Role>}
*/
this.roles = new Collection();
@@ -51,13 +51,13 @@ class Guild {
if (!data) return;
if (data.unavailable) {
/**
* Whether the guild is available to access. If it is not available, it indicates a server outage.
* Whether the guild is available to access. If it is not available, it indicates a server outage
* @type {boolean}
*/
this.available = false;
/**
* The Unique ID of the Guild, useful for comparisons.
* The Unique ID of the guild, useful for comparisons
* @type {Snowflake}
*/
this.id = data.id;
@@ -68,7 +68,7 @@ class Guild {
}
/**
* Sets up the Guild
* Sets up the guild.
* @param {*} data The raw data of the guild
* @private
*/
@@ -80,13 +80,13 @@ class Guild {
this.name = data.name;
/**
* The hash of the guild icon, or null if there is no icon.
* The hash of the guild icon
* @type {?string}
*/
this.icon = data.icon;
/**
* The hash of the guild splash image, or null if no splash (VIP only)
* The hash of the guild splash image (VIP only)
* @type {?string}
*/
this.splash = data.splash;
@@ -110,7 +110,7 @@ class Guild {
this.large = Boolean('large' in data ? data.large : this.large);
/**
* An array of guild features.
* An array of guild features
* @type {Object[]}
*/
this.features = data.features;
@@ -122,31 +122,31 @@ class Guild {
this.applicationID = data.application_id;
/**
* The time in seconds before a user is counted as "away from keyboard".
* The time in seconds before a user is counted as "away from keyboard"
* @type {?number}
*/
this.afkTimeout = data.afk_timeout;
/**
* The ID of the voice channel where AFK members are moved.
* The ID of the voice channel where AFK members are moved
* @type {?string}
*/
this.afkChannelID = data.afk_channel_id;
/**
* Whether embedded images are enabled on this guild.
* Whether embedded images are enabled on this guild
* @type {boolean}
*/
this.embedEnabled = data.embed_enabled;
/**
* The verification level of the guild.
* The verification level of the guild
* @type {number}
*/
this.verificationLevel = data.verification_level;
/**
* The explicit content filter level of the guild.
* The explicit content filter level of the guild
* @type {number}
*/
this.explicitContentFilter = data.explicit_content_filter;
@@ -168,7 +168,7 @@ class Guild {
if (data.owner_id) {
/**
* The user ID of this guild's owner.
* The user ID of this guild's owner
* @type {Snowflake}
*/
this.ownerID = data.owner_id;
@@ -253,7 +253,7 @@ class Guild {
}
/**
* Gets the URL to this guild's icon (if it has one, otherwise it returns null)
* The URL to this guild's icon
* @type {?string}
* @readonly
*/
@@ -263,7 +263,7 @@ class Guild {
}
/**
* Gets the URL to this guild's splash (if it has one, otherwise it returns null)
* The URL to this guild's splash
* @type {?string}
* @readonly
*/
@@ -282,7 +282,7 @@ class Guild {
}
/**
* If the client is connected to any voice channel in this guild, this will be the relevant VoiceConnection.
* If the client is connected to any voice channel in this guild, this will be the relevant VoiceConnection
* @type {?VoiceConnection}
* @readonly
*/
@@ -292,7 +292,7 @@ class Guild {
}
/**
* The `#general` TextChannel of the guild.
* The `#general` TextChannel of the guild
* @type {TextChannel}
* @readonly
*/
@@ -301,7 +301,7 @@ class Guild {
}
/**
* Get the position of this guild
* The position of this guild
* <warn>This is only available when using a user account.</warn>
* @type {?number}
*/
@@ -312,7 +312,7 @@ class Guild {
}
/**
* The `@everyone` Role of the guild.
* The `@everyone` Role of the guild
* @type {Role}
* @readonly
*/
@@ -321,7 +321,7 @@ class Guild {
}
/**
* Fetches a collection of roles in the current guild sorted by position.
* Fetches a collection of roles in the current guild sorted by position
* @type {Collection<Snowflake, Role>}
* @readonly
* @private
@@ -335,7 +335,7 @@ class Guild {
* @param {UserResolvable} user The user that you want to obtain the GuildMember of
* @returns {?GuildMember}
* @example
* // get the guild member of a user
* // Get the guild member of a user
* const member = guild.member(message.author);
*/
member(user) {
@@ -373,7 +373,7 @@ class Guild {
}
/**
* Fetch available voice regions
* Fetch available voice regions.
* @returns {Collection<string, VoiceRegion>}
*/
fetchVoiceRegions() {
@@ -381,7 +381,7 @@ class Guild {
}
/**
* Fetch audit logs for this guild
* Fetch audit logs for this guild.
* @param {Object} [options={}] Options for fetching audit logs
* @param {Snowflake|GuildAuditLogsEntry} [options.before] Limit to entries from before specified entry
* @param {Snowflake|GuildAuditLogsEntry} [options.after] Limit to entries from after specified entry
@@ -483,7 +483,7 @@ class Guild {
}
/**
* The data for editing a guild
* The data for editing a guild.
* @typedef {Object} GuildEditData
* @property {string} [name] The name of the guild
* @property {string} [region] The region of the guild
@@ -496,11 +496,11 @@ class Guild {
*/
/**
* Updates the Guild with new information - e.g. a new name.
* Updates the guild with new information - e.g. a new name.
* @param {GuildEditData} data The data to update the guild with
* @returns {Promise<Guild>}
* @example
* // set the guild name and region
* // Set the guild name and region
* guild.edit({
* name: 'Discord Guild',
* region: 'london',
@@ -517,7 +517,7 @@ class Guild {
* @param {string} name The new name of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild name
* // Edit the guild name
* guild.setName('Discord Guild')
* .then(updated => console.log(`Updated guild name to ${guild.name}`))
* .catch(console.error);
@@ -528,10 +528,10 @@ class Guild {
/**
* Edit the region of the guild.
* @param {string} region The new region of the guild.
* @param {string} region The new region of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild region
* // Edit the guild region
* guild.setRegion('london')
* .then(updated => console.log(`Updated guild region to ${guild.region}`))
* .catch(console.error);
@@ -545,7 +545,7 @@ class Guild {
* @param {number} verificationLevel The new verification level of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild verification level
* // Edit the guild verification level
* guild.setVerificationLevel(1)
* .then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
* .catch(console.error);
@@ -559,7 +559,7 @@ class Guild {
* @param {ChannelResolvable} afkChannel The new AFK channel
* @returns {Promise<Guild>}
* @example
* // edit the guild AFK channel
* // Edit the guild AFK channel
* guild.setAFKChannel(channel)
* .then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel}`))
* .catch(console.error);
@@ -573,7 +573,7 @@ class Guild {
* @param {number} afkTimeout The time in seconds that a user must be idle to be considered AFK
* @returns {Promise<Guild>}
* @example
* // edit the guild AFK channel
* // Edit the guild AFK channel
* guild.setAFKTimeout(60)
* .then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
* .catch(console.error);
@@ -587,7 +587,7 @@ class Guild {
* @param {Base64Resolvable} icon The new icon of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild icon
* // Edit the guild icon
* guild.setIcon(fs.readFileSync('./icon.png'))
* .then(updated => console.log('Updated the guild icon'))
* .catch(console.error);
@@ -601,7 +601,7 @@ class Guild {
* @param {GuildMemberResolvable} owner The new owner of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild owner
* // Edit the guild owner
* guild.setOwner(guild.members.first())
* .then(updated => console.log(`Updated the guild owner to ${updated.owner.username}`))
* .catch(console.error);
@@ -615,7 +615,7 @@ class Guild {
* @param {Base64Resolvable} splash The new splash screen of the guild
* @returns {Promise<Guild>}
* @example
* // edit the guild splash
* // Edit the guild splash
* guild.setIcon(fs.readFileSync('./splash.png'))
* .then(updated => console.log('Updated the guild splash'))
* .catch(console.error);
@@ -637,16 +637,16 @@ class Guild {
}
/**
* Marks all messages in this guild as read
* Marks all messages in this guild as read.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<Guild>} this guild
* @returns {Promise<Guild>} This guild
*/
acknowledge() {
return this.client.rest.methods.ackGuild(this);
}
/**
* Allow direct messages from guild members
* Allow direct messages from guild members.
* @param {boolean} allow Whether to allow direct messages
* @returns {Promise<Guild>}
*/
@@ -666,7 +666,7 @@ class Guild {
* If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot
* be resolved, the user ID will be the result.
* @example
* // ban a user by ID (or with a user/guild member object)
* // Ban a user by ID (or with a user/guild member object)
* guild.ban('some user ID')
* .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`))
* .catch(console.error);
@@ -685,7 +685,7 @@ class Guild {
* @param {UserResolvable} user The user to unban
* @returns {Promise<User>}
* @example
* // unban a user by ID (or with a user/guild member object)
* // Unban a user by ID (or with a user/guild member object)
* guild.unban('some user ID')
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
* .catch(console.error);
@@ -700,12 +700,12 @@ class Guild {
* @param {boolean} [dry=false] If true, will return number of users that will be kicked, without actually doing it
* @returns {Promise<number>} The number of members that were/will be kicked
* @example
* // see how many members will be pruned
* // See how many members will be pruned
* guild.pruneMembers(12, true)
* .then(pruned => console.log(`This will prune ${pruned} people!`))
* .catch(console.error);
* @example
* // actually prune the members
* // Actually prune the members
* guild.pruneMembers(12)
* .then(pruned => console.log(`I just pruned ${pruned} people!`))
* .catch(console.error);
@@ -730,7 +730,7 @@ class Guild {
* @param {Array<PermissionOverwrites|Object>} overwrites Permission overwrites to apply to the new channel
* @returns {Promise<TextChannel|VoiceChannel>}
* @example
* // create a new text channel
* // Create a new text channel
* guild.createChannel('new-general', 'text')
* .then(channel => console.log(`Created new channel ${channel}`))
* .catch(console.error);
@@ -764,12 +764,12 @@ class Guild {
* @param {RoleData} [data] The data to update the role with
* @returns {Promise<Role>}
* @example
* // create a new role
* // Create a new role
* guild.createRole()
* .then(role => console.log(`Created role ${role}`))
* .catch(console.error);
* @example
* // create a new role with data
* // Create a new role with data
* guild.createRole({
* name: 'Super Cool People',
* color: 'BLUE',
@@ -783,17 +783,17 @@ class Guild {
/**
* Creates a new custom emoji in the guild.
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji.
* @param {string} name The name for the emoji.
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji
* @param {string} name The name for the emoji
* @param {Collection<Snowflake, Role>|Role[]} [roles] Roles to limit the emoji to
* @returns {Promise<Emoji>} The created emoji.
* @returns {Promise<Emoji>} The created emoji
* @example
* // create a new emoji from a url
* // Create a new emoji from a url
* guild.createEmoji('https://i.imgur.com/w3duR07.png', 'rip')
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error);
* @example
* // create a new emoji from a file on your computer
* // Create a new emoji from a file on your computer
* guild.createEmoji('./memes/banana.png', 'banana')
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error);
@@ -813,7 +813,7 @@ class Guild {
/**
* Delete an emoji.
* @param {Emoji|string} emoji The emoji to delete.
* @param {Emoji|string} emoji The emoji to delete
* @returns {Promise}
*/
deleteEmoji(emoji) {
@@ -822,10 +822,10 @@ class Guild {
}
/**
* Causes the Client to leave the guild.
* Causes the client to leave the guild.
* @returns {Promise<Guild>}
* @example
* // leave a guild
* // Leave a guild
* guild.leave()
* .then(g => console.log(`Left the guild ${g}`))
* .catch(console.error);
@@ -835,10 +835,10 @@ class Guild {
}
/**
* Causes the Client to delete the guild.
* Causes the client to delete the guild.
* @returns {Promise<Guild>}
* @example
* // delete a guild
* // Delete a guild
* guild.delete()
* .then(g => console.log(`Deleted the guild ${g}`))
* .catch(console.error);
@@ -848,10 +848,10 @@ class Guild {
}
/**
* Whether this Guild equals another Guild. It compares all properties, so for most operations
* Whether this guild equals another guild. It compares all properties, so for most operations
* it is advisable to just compare `guild.id === guild2.id` as it is much faster and is often
* what most users need.
* @param {Guild} guild Guild to compare with
* @param {Guild} guild The guild to compare with
* @returns {boolean}
*/
equals(guild) {
@@ -882,13 +882,13 @@ class Guild {
}
/**
* When concatenated with a string, this automatically concatenates the guild's name instead of the Guild object.
* When concatenated with a string, this automatically concatenates the guild's name instead of the guild object.
* @returns {string}
* @example
* // logs: Hello from My Guild!
* // Logs: Hello from My Guild!
* console.log(`Hello from ${guild}!`);
* @example
* // logs: Hello from My Guild!
* // Logs: Hello from My Guild!
* console.log('Hello from ' + guild + '!');
*/
toString() {
@@ -940,7 +940,7 @@ class Guild {
if (this.client.ws.connection.status === Constants.Status.READY && notSame) {
/**
* Emitted whenever a guild member changes - i.e. new role, removed role, nickname
* Emitted whenever a guild member changes - i.e. new role, removed role, nickname.
* @event Client#guildMemberUpdate
* @param {GuildMember} oldMember The member before the update
* @param {GuildMember} newMember The member after the update
@@ -963,7 +963,7 @@ class Guild {
if (member && member.speaking !== speaking) {
member.speaking = speaking;
/**
* Emitted once a guild member starts/stops speaking
* Emitted once a guild member starts/stops speaking.
* @event Client#guildMemberSpeaking
* @param {GuildMember} member The member that started/stopped speaking
* @param {boolean} speaking Whether or not the member is speaking
@@ -981,8 +981,8 @@ class Guild {
}
/**
* Set the position of a role in this guild
* @param {string|Role} role The role to edit, can be a role object or a role ID.
* Set the position of a role in this guild.
* @param {string|Role} role The role to edit, can be a role object or a role ID
* @param {number} position The new position of the role
* @param {boolean} [relative=false] Position Moves the role relative to its current position
* @returns {Promise<Guild>}
@@ -1005,8 +1005,8 @@ class Guild {
}
/**
* Set the position of a channel in this guild
* @param {string|GuildChannel} channel The channel to edit, can be a channel object or a channel ID.
* Set the position of a channel in this guild.
* @param {string|GuildChannel} channel The channel to edit, can be a channel object or a channel ID
* @param {number} position The new position of the channel
* @param {boolean} [relative=false] Position Moves the channel relative to its current position
* @returns {Promise<Guild>}
@@ -1030,7 +1030,7 @@ class Guild {
/**
* Fetches a collection of channels in the current guild sorted by position.
* @param {string} type Channel type
* @param {string} type The channel type
* @returns {Collection<Snowflake, GuildChannel>}
* @private
*/

View File

@@ -41,7 +41,7 @@ class GuildAuditLogs {
if (data.users) for (const user of data.users) guild.client.dataManager.newUser(user);
/**
* Entries for this Guild's audit logs
* The entries for this guild's audit logs
* @type {GuildAuditLogsEntry[]}
*/
this.entries = [];
@@ -49,7 +49,7 @@ class GuildAuditLogs {
}
/**
* Handles possible promises for entry targets
* Handles possible promises for entry targets.
* @returns {GuildAuditLogs}
*/
static build(...args) {
@@ -60,8 +60,8 @@ class GuildAuditLogs {
}
/**
* Find target type from entry action
* @param {number} target Action target
* Find target type from entry action.
* @param {number} target The action target
* @returns {?string}
*/
static targetType(target) {
@@ -77,8 +77,8 @@ class GuildAuditLogs {
/**
* Find action type from entry action
* @param {string} action Action target
* Find action type from entry action.
* @param {string} action The action target
* @returns {string}
*/
static actionType(action) {
@@ -123,13 +123,13 @@ class GuildAuditLogsEntry {
constructor(guild, data) {
const targetType = GuildAuditLogs.targetType(data.action_type);
/**
* Target type of this entry
* The target type of this entry
* @type {string}
*/
this.targetType = targetType;
/**
* Action type of this entry
* The action type of this entry
* @type {string}
*/
this.actionType = GuildAuditLogs.actionType(data.action_type);
@@ -141,13 +141,13 @@ class GuildAuditLogsEntry {
this.action = Object.keys(Actions).find(k => Actions[k] === data.action_type);
/**
* Reason of this entry
* The reason of this entry
* @type {?string}
*/
this.reason = data.reason || null;
/**
* User that executed this entry
* The user that executed this entry
* @type {User}
*/
this.executor = guild.client.users.get(data.user_id);
@@ -159,14 +159,14 @@ class GuildAuditLogsEntry {
this.changes = data.changes ? data.changes.map(c => ({ name: c.key, old: c.old_value, new: c.new_value })) : null;
/**
* ID of this entry
* The ID of this entry
* @type {Snowflake}
*/
this.id = data.id;
if ([Targets.USER, Targets.GUILD].includes(targetType)) {
/**
* Target of this entry
* The target of this entry
* @type {?Guild|User|Role|Emoji|Invite|Webhook}
*/
this.target = guild.client[`${targetType.toLowerCase()}s`].get(data.target_id);

View File

@@ -5,7 +5,7 @@ const Permissions = require('../util/Permissions');
const Collection = require('../util/Collection');
/**
* Represents a guild channel (i.e. text channels and voice channels)
* Represents a guild channel (i.e. text channels and voice channels).
* @extends {Channel}
*/
class GuildChannel extends Channel {
@@ -29,13 +29,13 @@ class GuildChannel extends Channel {
this.name = data.name;
/**
* The position of the channel in the list.
* The position of the channel in the list
* @type {number}
*/
this.position = data.position;
/**
* A map of permission overwrites in this channel for roles and users.
* A map of permission overwrites in this channel for roles and users
* @type {Collection<Snowflake, PermissionOverwrites>}
*/
this.permissionOverwrites = new Collection();
@@ -124,7 +124,7 @@ class GuildChannel extends Channel {
}
/**
* An object mapping permission flags to `true` (enabled) or `false` (disabled)
* An object mapping permission flags to `true` (enabled) or `false` (disabled).
* ```js
* {
* 'SEND_MESSAGES': true,
@@ -140,7 +140,7 @@ class GuildChannel extends Channel {
* @param {PermissionOverwriteOptions} options The configuration for the update
* @returns {Promise}
* @example
* // overwrite permissions for a message author
* // Overwrite permissions for a message author
* message.channel.overwritePermissions(message.author, {
* SEND_MESSAGES: false
* })
@@ -190,7 +190,7 @@ class GuildChannel extends Channel {
}
/**
* The data for a guild channel
* The data for a guild channel.
* @typedef {Object} ChannelData
* @property {string} [name] The name of the channel
* @property {number} [position] The position of the channel
@@ -200,11 +200,11 @@ class GuildChannel extends Channel {
*/
/**
* Edits the channel
* Edits the channel.
* @param {ChannelData} data The new data for the channel
* @returns {Promise<GuildChannel>}
* @example
* // edit a channel
* // Edit a channel
* channel.edit({name: 'new-channel'})
* .then(c => console.log(`Edited channel ${c}`))
* .catch(console.error);
@@ -214,11 +214,11 @@ class GuildChannel extends Channel {
}
/**
* Set a new name for the guild channel
* Set a new name for the guild channel.
* @param {string} name The new name for the guild channel
* @returns {Promise<GuildChannel>}
* @example
* // set a new channel name
* // Set a new channel name
* channel.setName('not_general')
* .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
* .catch(console.error);
@@ -228,12 +228,12 @@ class GuildChannel extends Channel {
}
/**
* Set a new position for the guild channel
* Set a new position for the guild channel.
* @param {number} position The new position for the guild channel
* @param {boolean} [relative=false] Move the position relative to its current value
* @returns {Promise<GuildChannel>}
* @example
* // set a new channel position
* // Set a new channel position
* channel.setPosition(2)
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
* .catch(console.error);
@@ -243,11 +243,11 @@ class GuildChannel extends Channel {
}
/**
* Set a new topic for the guild channel
* Set a new topic for the guild channel.
* @param {string} topic The new topic for the guild channel
* @returns {Promise<GuildChannel>}
* @example
* // set a new channel topic
* // Set a new channel topic
* channel.setTopic('needs more rate limiting')
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
* .catch(console.error);
@@ -257,13 +257,13 @@ class GuildChannel extends Channel {
}
/**
* Options given when creating a guild channel invite
* Options given when creating a guild channel invite.
* @typedef {Object} InviteOptions
*/
/**
* Create an invite to this guild channel
* Create an invite to this guild channel.
* @param {InviteOptions} [options={}] Options for the invite
* @param {boolean} [options.temporary=false] Whether members that joined via the invite should be automatically
* kicked after 24 hours if they have not yet received a role
@@ -276,7 +276,7 @@ class GuildChannel extends Channel {
}
/**
* Clone this channel
* Clone this channel.
* @param {string} [name=this.name] Optional name for the new channel, otherwise it has the name of this channel
* @param {boolean} [withPermissions=true] Whether to clone the channel with this channel's permission overwrites
* @param {boolean} [withTopic=true] Whether to clone the channel with this channel's topic
@@ -313,7 +313,7 @@ class GuildChannel extends Channel {
}
/**
* Whether the channel is deletable by the client user.
* Whether the channel is deletable by the client user
* @type {boolean}
* @readonly
*/

View File

@@ -6,13 +6,13 @@ const Presence = require('./Presence').Presence;
const util = require('util');
/**
* Represents a member of a guild on Discord
* Represents a member of a guild on Discord.
* @implements {TextBasedChannel}
*/
class GuildMember {
constructor(guild, data) {
/**
* The Client that instantiated this GuildMember
* The client that instantiated this GuildMember
* @name GuildMember#client
* @type {Client}
* @readonly
@@ -35,13 +35,13 @@ class GuildMember {
if (data) this.setup(data);
/**
* The ID of the last message sent by the member in their guild, if one was sent.
* The ID of the last message sent by the member in their guild, if one was sent
* @type {?Snowflake}
*/
this.lastMessageID = null;
/**
* The Message object of the last message sent by the member in their guild, if one was sent.
* The Message object of the last message sent by the member in their guild, if one was sent
* @type {?Message}
*/
this.lastMessage = null;
@@ -125,7 +125,7 @@ class GuildMember {
}
/**
* A list of roles that are applied to this GuildMember, mapped by the role ID.
* A list of roles that are applied to this GuildMember, mapped by the role ID
* @type {Collection<Snowflake, Role>}
* @readonly
*/
@@ -144,7 +144,7 @@ class GuildMember {
}
/**
* The role of the member with the highest position.
* The role of the member with the highest position
* @type {Role}
* @readonly
*/
@@ -153,7 +153,7 @@ class GuildMember {
}
/**
* The role of the member used to set their color.
* The role of the member used to set their color
* @type {?Role}
* @readonly
*/
@@ -164,7 +164,7 @@ class GuildMember {
}
/**
* The displayed color of the member in base 10.
* The displayed color of the member in base 10
* @type {number}
* @readonly
*/
@@ -174,7 +174,7 @@ class GuildMember {
}
/**
* The displayed color of the member in hexadecimal.
* The displayed color of the member in hexadecimal
* @type {string}
* @readonly
*/
@@ -184,7 +184,7 @@ class GuildMember {
}
/**
* The role of the member used to hoist them in a separate category in the users list.
* The role of the member used to hoist them in a separate category in the users list
* @type {?Role}
* @readonly
*/
@@ -255,7 +255,7 @@ class GuildMember {
}
/**
* Whether the member is kickable by the client user.
* Whether the member is kickable by the client user
* @type {boolean}
* @readonly
*/
@@ -268,7 +268,7 @@ class GuildMember {
}
/**
* Whether the member is bannable by the client user.
* Whether the member is bannable by the client user
* @type {boolean}
* @readonly
*/
@@ -283,7 +283,7 @@ class GuildMember {
/**
* Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
* taking into account roles and permission overwrites.
* @param {ChannelResolvable} channel Guild channel to use as context
* @param {ChannelResolvable} channel The guild channel to use as context
* @returns {?Permissions}
*/
permissionsIn(channel) {
@@ -333,7 +333,7 @@ class GuildMember {
}
/**
* The data for editing a guild member
* The data for editing a guild member.
* @typedef {Object} GuildMemberEditData
* @property {string} [nick] The nickname to set for the member
* @property {Collection<Snowflake, Role>|Role[]|Snowflake[]} [roles] The roles or role IDs to apply
@@ -343,7 +343,7 @@ class GuildMember {
*/
/**
* Edit a guild member
* Edit a guild member.
* @param {GuildMemberEditData} data The data to edit the member with
* @returns {Promise<GuildMember>}
*/
@@ -352,7 +352,7 @@ class GuildMember {
}
/**
* Mute/unmute a user
* Mute/unmute a user.
* @param {boolean} mute Whether or not the member should be muted
* @returns {Promise<GuildMember>}
*/
@@ -361,7 +361,7 @@ class GuildMember {
}
/**
* Deafen/undeafen a user
* Deafen/undeafen a user.
* @param {boolean} deaf Whether or not the member should be deafened
* @returns {Promise<GuildMember>}
*/
@@ -447,7 +447,7 @@ class GuildMember {
}
/**
* Set the nickname for the guild member
* Set the nickname for the guild member.
* @param {string} nick The nickname for the guild member
* @returns {Promise<GuildMember>}
*/
@@ -456,7 +456,7 @@ class GuildMember {
}
/**
* Creates a DM channel between the client and the member
* Creates a DM channel between the client and the member.
* @returns {Promise<DMChannel>}
*/
createDM() {
@@ -464,7 +464,7 @@ class GuildMember {
}
/**
* Deletes any DMs with this guild member
* Deletes any DMs with this guild member.
* @returns {Promise<DMChannel>}
*/
deleteDM() {
@@ -472,7 +472,7 @@ class GuildMember {
}
/**
* Kick this member from the guild
* Kick this member from the guild.
* @param {string} [reason] Reason for kicking user
* @returns {Promise<GuildMember>}
*/
@@ -498,7 +498,7 @@ class GuildMember {
* When concatenated with a string, this automatically concatenates the user's mention instead of the Member object.
* @returns {string}
* @example
* // logs: Hello from <@123456789>!
* // Logs: Hello from <@123456789>!
* console.log(`Hello from ${member}!`);
*/
toString() {

View File

@@ -42,8 +42,8 @@ class Invite {
setup(data) {
/**
* The guild the invite is for. If this guild is already known, this will be a Guild object. If the guild is
* unknown, this will be a PartialGuild object.
* The guild the invite is for. If this guild is already known, this will be a guild object. If the guild is
* unknown, this will be a PartialGuild object
* @type {Guild|PartialGuild}
*/
this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild);
@@ -137,7 +137,7 @@ class Invite {
}
/**
* Deletes this invite
* Deletes this invite.
* @returns {Promise<Invite>}
*/
delete() {
@@ -148,7 +148,7 @@ class Invite {
* When concatenated with a string, this automatically concatenates the invite's URL instead of the object.
* @returns {string}
* @example
* // logs: Invite: https://discord.gg/A1b2C3
* // Logs: Invite: https://discord.gg/A1b2C3
* console.log(`Invite: ${invite}`);
*/
toString() {

View File

@@ -10,12 +10,12 @@ const Permissions = require('../util/Permissions');
let GuildMember;
/**
* Represents a message on Discord
* Represents a message on Discord.
*/
class Message {
constructor(channel, data, client) {
/**
* The Client that instantiated the Message
* The client that instantiated the Message
* @name Message#client
* @type {Client}
* @readonly
@@ -94,7 +94,7 @@ class Message {
this.embeds = data.embeds.map(e => new Embed(this, e));
/**
* A collection of attachments in the message - e.g. Pictures - mapped by their ID.
* A collection of attachments in the message - e.g. Pictures - mapped by their ID
* @type {Collection<Snowflake, MessageAttachment>}
*/
this.attachments = new Collection();
@@ -113,7 +113,7 @@ class Message {
this.editedTimestamp = data.edited_timestamp ? new Date(data.edited_timestamp).getTime() : null;
/**
* A collection of reactions to this message, mapped by the reaction "id".
* A collection of reactions to this message, mapped by the reaction ID
* @type {Collection<Snowflake, MessageReaction>}
*/
this.reactions = new Collection();
@@ -151,7 +151,7 @@ class Message {
}
/**
* Updates the message
* Updates the message.
* @param {Object} data Raw Discord message update data
* @private
*/
@@ -210,7 +210,7 @@ class Message {
/**
* The message contents with all mentions replaced by the equivalent text. If mentions cannot be resolved to a name,
* the relevant mention in the message content will not be converted.
* the relevant mention in the message content will not be converted
* @type {string}
* @readonly
*/
@@ -248,11 +248,11 @@ class Message {
/**
* Creates a reaction collector.
* @param {CollectorFilter} filter The filter to apply.
* @param {ReactionCollectorOptions} [options={}] Options to send to the collector.
* @param {CollectorFilter} filter The filter to apply
* @param {ReactionCollectorOptions} [options={}] Options to send to the collector
* @returns {ReactionCollector}
* @example
* // create a reaction collector
* // Create a reaction collector
* const collector = message.createReactionCollector(
* (reaction, user) => reaction.emoji.id === '👌' && user.id === 'someID',
* { time: 15000 }
@@ -288,8 +288,8 @@ class Message {
}
/**
* An array of cached versions of the message, including the current version.
* Sorted from latest (first) to oldest (last).
* An array of cached versions of the message, including the current version
* Sorted from latest (first) to oldest (last)
* @type {Message[]}
* @readonly
*/
@@ -300,7 +300,7 @@ class Message {
}
/**
* Whether the message is editable by the client user.
* Whether the message is editable by the client user
* @type {boolean}
* @readonly
*/
@@ -309,7 +309,7 @@ class Message {
}
/**
* Whether the message is deletable by the client user.
* Whether the message is deletable by the client user
* @type {boolean}
* @readonly
*/
@@ -320,7 +320,7 @@ class Message {
}
/**
* Whether the message is pinnable by the client user.
* Whether the message is pinnable by the client user
* @type {boolean}
* @readonly
*/
@@ -331,8 +331,8 @@ class Message {
/**
* Whether or not a user, channel or role is mentioned in this message.
* @param {GuildChannel|User|Role|string} data either a guild channel, user or a role object, or a string representing
* the ID of any of these.
* @param {GuildChannel|User|Role|string} data Either a guild channel, user or a role object, or a string representing
* the ID of any of these
* @returns {boolean}
*/
isMentioned(data) {
@@ -343,7 +343,7 @@ class Message {
/**
* Whether or not a guild member is mentioned in this message. Takes into account
* user mentions, role mentions, and @everyone/@here mentions.
* @param {GuildMember|User} member Member/user to check for a mention of
* @param {GuildMember|User} member The member/user to check for a mention of
* @returns {boolean}
*/
isMemberMentioned(member) {
@@ -356,19 +356,19 @@ class Message {
}
/**
* Options that can be passed into editMessage
* Options that can be passed into editMessage.
* @typedef {Object} MessageEditOptions
* @property {Object} [embed] An embed to be added/edited
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
*/
/**
* Edit the content of the message
* Edit the content of the message.
* @param {StringResolvable} [content] The new content for the message
* @param {MessageEditOptions} [options] The options to provide
* @returns {Promise<Message>}
* @example
* // update the content of a message
* // Update the content of a message
* message.edit('This is my new content!')
* .then(msg => console.log(`Updated the content of a message from ${msg.author}`))
* .catch(console.error);
@@ -384,8 +384,8 @@ class Message {
}
/**
* Edit the content of the message, with a code block
* @param {string} lang Language for the code block
* Edit the content of the message, with a code block.
* @param {string} lang The language for the code block
* @param {StringResolvable} content The new content for the message
* @returns {Promise<Message>}
*/
@@ -395,7 +395,7 @@ class Message {
}
/**
* Pins this message to the channel's pinned messages
* Pins this message to the channel's pinned messages.
* @returns {Promise<Message>}
*/
pin() {
@@ -403,7 +403,7 @@ class Message {
}
/**
* Unpins this message from the channel's pinned messages
* Unpins this message from the channel's pinned messages.
* @returns {Promise<Message>}
*/
unpin() {
@@ -411,8 +411,8 @@ class Message {
}
/**
* Add a reaction to the message
* @param {string|Emoji|ReactionEmoji} emoji Emoji to react with
* Add a reaction to the message.
* @param {string|Emoji|ReactionEmoji} emoji The emoji to react with
* @returns {Promise<MessageReaction>}
*/
react(emoji) {
@@ -423,7 +423,7 @@ class Message {
}
/**
* Remove all reactions from a message
* Remove all reactions from a message.
* @returns {Promise<Message>}
*/
clearReactions() {
@@ -431,11 +431,11 @@ class Message {
}
/**
* Deletes the message
* Deletes the message.
* @param {number} [timeout=0] How long to wait to delete the message in milliseconds
* @returns {Promise<Message>}
* @example
* // delete a message
* // Delete a message
* message.delete()
* .then(msg => console.log(`Deleted message from ${msg.author}`))
* .catch(console.error);
@@ -453,12 +453,12 @@ class Message {
}
/**
* Reply to the message
* Reply to the message.
* @param {StringResolvable} [content] The content for the message
* @param {MessageOptions} [options] The options to provide
* @returns {Promise<Message|Message[]>}
* @example
* // reply to a message
* // Reply to a message
* message.reply('Hey, I\'m a reply!')
* .then(msg => console.log(`Sent a reply to ${msg.author}`))
* .catch(console.error);
@@ -474,7 +474,7 @@ class Message {
}
/**
* Marks the message as read
* Marks the message as read.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<Message>}
*/
@@ -525,7 +525,7 @@ class Message {
* When concatenated with a string, this automatically concatenates the message's content instead of the object.
* @returns {string}
* @example
* // logs: Message: This is a message!
* // Logs: Message: This is a message!
* console.log(`Message: ${message}`);
*/
toString() {

View File

@@ -1,10 +1,10 @@
/**
* Represents an attachment in a message
* Represents an attachment in a message.
*/
class MessageAttachment {
constructor(message, data) {
/**
* The Client that instantiated this MessageAttachment.
* The client that instantiated this MessageAttachment
* @name MessageAttachment#client
* @type {Client}
* @readonly
@@ -12,7 +12,7 @@ class MessageAttachment {
Object.defineProperty(this, 'client', { value: message.client });
/**
* The message this attachment is part of.
* The message this attachment is part of
* @type {Message}
*/
this.message = message;

View File

@@ -3,8 +3,8 @@ const util = require('util');
/**
* @typedef {CollectorOptions} MessageCollectorOptions
* @property {number} max The maximum amount of messages to process.
* @property {number} maxMatches The maximum amount of messages to collect.
* @property {number} max The maximum amount of messages to process
* @property {number} maxMatches The maximum amount of messages to collect
*/
/**
@@ -14,36 +14,35 @@ const util = require('util');
class MessageCollector extends Collector {
/**
* @param {TextChannel|DMChannel|GroupDMChannel} channel The channel.
* @param {CollectorFilter} filter The filter to be applied to this collector.
* @param {MessageCollectorOptions} options The options to be applied to this collector.
* @param {TextChannel|DMChannel|GroupDMChannel} channel The channel
* @param {CollectorFilter} filter The filter to be applied to this collector
* @param {MessageCollectorOptions} options The options to be applied to this collector
* @emits MessageCollector#message
*/
constructor(channel, filter, options = {}) {
super(channel.client, filter, options);
/**
* @type {TextBasedChannel} channel The channel.
* @type {TextBasedChannel} channel The channel
*/
this.channel = channel;
/**
* Total number of messages that were received in the
* channel during message collection.
* Total number of messages that were received in the channel during message collection
* @type {number}
*/
this.received = 0;
this.client.on('message', this.listener);
// For backwards compatibility (remove in v12).
// For backwards compatibility (remove in v12)
if (this.options.max) this.options.maxProcessed = this.options.max;
if (this.options.maxMatches) this.options.max = this.options.maxMatches;
this._reEmitter = message => {
/**
* Emitted when the collector receives a message.
* @event MessageCollector#message
* @param {Message} message The message.
* @param {Message} message The message
* @deprecated
*/
this.emit('message', message);
@@ -51,7 +50,7 @@ class MessageCollector extends Collector {
this.on('collect', this._reEmitter);
}
// TODO: Remove me in v12
// Remove in v12
on(eventName, listener) {
if (eventName === 'message') {
listener = util.deprecate(listener, 'MessageCollector will soon no longer emit "message", use "collect" instead');
@@ -61,8 +60,8 @@ class MessageCollector extends Collector {
/**
* Handle an incoming message for possible collection.
* @param {Message} message The message that could be collected.
* @returns {?{key: Snowflake, value: Message}} Message data to collect.
* @param {Message} message The message that could be collected
* @returns {?{key: Snowflake, value: Message}} Message data to collect
* @private
*/
handle(message) {
@@ -76,7 +75,7 @@ class MessageCollector extends Collector {
/**
* Check after collection to see if the collector is done.
* @returns {?string} Reason to end the collector, if any.
* @returns {?string} Reason to end the collector, if any
* @private
*/
postCheck() {

View File

@@ -29,13 +29,13 @@ class MessageEmbed {
this.type = data.type;
/**
* The title of this embed, if there is one
* The title of this embed
* @type {?string}
*/
this.title = data.title;
/**
* The description of this embed, if there is one
* The description of this embed
* @type {?string}
*/
this.description = data.description;
@@ -66,31 +66,31 @@ class MessageEmbed {
this.createdTimestamp = data.timestamp;
/**
* The thumbnail of this embed, if there is one
* The thumbnail of this embed
* @type {?MessageEmbedThumbnail}
*/
this.thumbnail = data.thumbnail ? new MessageEmbedThumbnail(this, data.thumbnail) : null;
/**
* The image of this embed, if there is one
* The image of this embed
* @type {?MessageEmbedImage}
*/
this.image = data.image ? new MessageEmbedImage(this, data.image) : null;
/**
* The video of this embed, if there is one
* The video of this embed
* @type {?MessageEmbedVideo}
*/
this.video = data.video ? new MessageEmbedVideo(this, data.video) : null;
/**
* The author of this embed, if there is one
* The author of this embed
* @type {?MessageEmbedAuthor}
*/
this.author = data.author ? new MessageEmbedAuthor(this, data.author) : null;
/**
* The provider of this embed, if there is one
* The provider of this embed
* @type {?MessageEmbedProvider}
*/
this.provider = data.provider ? new MessageEmbedProvider(this, data.provider) : null;
@@ -112,7 +112,7 @@ class MessageEmbed {
}
/**
* The hexadecimal version of the embed color, with a leading hash.
* The hexadecimal version of the embed color, with a leading hash
* @type {string}
* @readonly
*/
@@ -124,7 +124,7 @@ class MessageEmbed {
}
/**
* Represents a thumbnail for a message embed
* Represents a thumbnail for a message embed.
*/
class MessageEmbedThumbnail {
constructor(embed, data) {
@@ -165,7 +165,7 @@ class MessageEmbedThumbnail {
}
/**
* Represents an image for a message embed
* Represents an image for a message embed.
*/
class MessageEmbedImage {
constructor(embed, data) {
@@ -206,7 +206,7 @@ class MessageEmbedImage {
}
/**
* Represents a video for a message embed
* Represents a video for a message embed.
*/
class MessageEmbedVideo {
constructor(embed, data) {
@@ -241,7 +241,7 @@ class MessageEmbedVideo {
}
/**
* Represents a provider for a message embed
* Represents a provider for a message embed.
*/
class MessageEmbedProvider {
constructor(embed, data) {
@@ -270,7 +270,7 @@ class MessageEmbedProvider {
}
/**
* Represents an author for a message embed
* Represents an author for a message embed.
*/
class MessageEmbedAuthor {
constructor(embed, data) {
@@ -305,7 +305,7 @@ class MessageEmbedAuthor {
}
/**
* Represents a field for a message embed
* Represents a field for a message embed.
*/
class MessageEmbedField {
constructor(embed, data) {
@@ -340,7 +340,7 @@ class MessageEmbedField {
}
/**
* Represents the footer of a message embed
* Represents the footer of a message embed.
*/
class MessageEmbedFooter {
constructor(embed, data) {

View File

@@ -1,7 +1,7 @@
const Collection = require('../util/Collection');
/**
* Keeps track of mentions in a {@link Message}
* Keeps track of mentions in a {@link Message}.
*/
class MessageMentions {
constructor(message, users, roles, everyone) {
@@ -56,14 +56,14 @@ class MessageMentions {
this._content = message.content;
/**
* Client the message is from
* The client the message is from
* @type {Client}
* @private
*/
this._client = message.client;
/**
* Guild the message is in
* The guild the message is in
* @type {?Guild}
* @private
*/

View File

@@ -3,7 +3,7 @@ const Emoji = require('./Emoji');
const ReactionEmoji = require('./ReactionEmoji');
/**
* Represents a reaction to a message
* Represents a reaction to a message.
*/
class MessageReaction {
constructor(message, emoji, count, me) {
@@ -20,13 +20,13 @@ class MessageReaction {
this.me = me;
/**
* The number of people that have given the same reaction.
* The number of people that have given the same reaction
* @type {number}
*/
this.count = count || 0;
/**
* The users that have given this reaction, mapped by their ID.
* The users that have given this reaction, mapped by their ID
* @type {Collection<Snowflake, User>}
*/
this.users = new Collection();
@@ -57,7 +57,7 @@ class MessageReaction {
/**
* Removes a user from this reaction.
* @param {UserResolvable} [user=this.message.client.user] User to remove the reaction of
* @param {UserResolvable} [user=this.message.client.user] The user to remove the reaction of
* @returns {Promise<MessageReaction>}
*/
remove(user = this.message.client.user) {
@@ -71,7 +71,7 @@ class MessageReaction {
/**
* Fetch all the users that gave this reaction. Resolves with a collection of users, mapped by their IDs.
* @param {number} [limit=100] the maximum amount of users to fetch, defaults to 100
* @param {number} [limit=100] The maximum amount of users to fetch, defaults to 100
* @returns {Promise<Collection<Snowflake, User>>}
*/
fetchUsers(limit = 100) {

View File

@@ -1,7 +1,7 @@
const Snowflake = require('../util/Snowflake');
/**
* Represents an OAuth2 Application
* Represents an OAuth2 Application.
*/
class OAuth2Application {
constructor(client, data) {
@@ -60,7 +60,7 @@ class OAuth2Application {
this.redirectURIs = data.redirect_uris;
/**
* If this app's bot requires a code grant when using the oauth2 flow
* If this app's bot requires a code grant when using the OAuth2 flow
* @type {boolean}
*/
this.botRequireCodeGrant = data.bot_require_code_grant;
@@ -84,7 +84,7 @@ class OAuth2Application {
this.bot = data.bot;
/**
* Flags for the app
* The flags for the app
* @type {number}
*/
this.flags = data.flags;
@@ -115,7 +115,7 @@ class OAuth2Application {
}
/**
* Reset the app's secret and bot token
* Reset the app's secret and bot token.
* @returns {OAuth2Application}
*/
reset() {

View File

@@ -11,7 +11,7 @@
class PartialGuild {
constructor(client, data) {
/**
* The Client that instantiated this PartialGuild
* The client that instantiated this PartialGuild
* @name PartialGuild#client
* @type {Client}
* @readonly
@@ -35,13 +35,13 @@ class PartialGuild {
this.name = data.name;
/**
* The hash of this guild's icon, or null if there is none.
* The hash of this guild's icon
* @type {?string}
*/
this.icon = data.icon;
/**
* The hash of the guild splash image, or null if no splash (VIP only)
* The hash of the guild splash image (VIP only)
* @type {?string}
*/
this.splash = data.splash;

View File

@@ -10,7 +10,7 @@ const Constants = require('../util/Constants');
class PartialGuildChannel {
constructor(client, data) {
/**
* The Client that instantiated this PartialGuildChannel
* The client that instantiated this PartialGuildChannel
* @name PartialGuildChannel#client
* @type {Client}
* @readonly

View File

@@ -1,5 +1,5 @@
/**
* Represents a user's presence
* Represents a user's presence.
*/
class Presence {
constructor(data = {}) {
@@ -15,7 +15,7 @@ class Presence {
this.status = data.status || 'offline';
/**
* The game that the user is playing, `null` if they aren't playing a game.
* The game that the user is playing
* @type {?Game}
*/
this.game = data.game ? new Game(data.game) : null;
@@ -28,7 +28,7 @@ class Presence {
/**
* Whether this presence is equal to another
* @param {Presence} presence Presence to compare with
* @param {Presence} presence The presence to compare with
* @returns {boolean}
*/
equals(presence) {
@@ -75,7 +75,7 @@ class Game {
/**
* Whether this game is equal to another game
* @param {Game} game Game to compare with
* @param {Game} game The game to compare with
* @returns {boolean}
*/
equals(game) {

View File

@@ -3,9 +3,9 @@ const Collection = require('../util/Collection');
/**
* @typedef {CollectorOptions} ReactionCollectorOptions
* @property {number} max The maximum total amount of reactions to collect.
* @property {number} maxEmojis The maximum number of emojis to collect.
* @property {number} maxUsers The maximum number of users to react.
* @property {number} max The maximum total amount of reactions to collect
* @property {number} maxEmojis The maximum number of emojis to collect
* @property {number} maxUsers The maximum number of users to react
*/
/**
@@ -15,27 +15,27 @@ const Collection = require('../util/Collection');
class ReactionCollector extends Collector {
/**
* @param {Message} message The message upon which to collect reactions.
* @param {CollectorFilter} filter The filter to apply to this collector.
* @param {ReactionCollectorOptions} [options={}] The options to apply to this collector.
* @param {Message} message The message upon which to collect reactions
* @param {CollectorFilter} filter The filter to apply to this collector
* @param {ReactionCollectorOptions} [options={}] The options to apply to this collector
*/
constructor(message, filter, options = {}) {
super(message.client, filter, options);
/**
* The message.
* The message
* @type {Message}
*/
this.message = message;
/**
* Users which have reacted.
* The users which have reacted
* @type {Collection}
*/
this.users = new Collection();
/**
* Total number of reactions collected.
* The total number of reactions collected
* @type {number}
*/
this.total = 0;
@@ -45,8 +45,8 @@ class ReactionCollector extends Collector {
/**
* Handle an incoming reaction for possible collection.
* @param {MessageReaction} reaction The reaction to possibly collect.
* @returns {?{key: Snowflake, value: MessageReaction}} Reaction data to collect.
* @param {MessageReaction} reaction The reaction to possibly collect
* @returns {?{key: Snowflake, value: MessageReaction}} Reaction data to collect
* @private
*/
handle(reaction) {
@@ -59,9 +59,9 @@ class ReactionCollector extends Collector {
/**
* Check after collection to see if the collector is done.
* @param {MessageReaction} reaction The reaction that was collected.
* @param {User} user The user that reacted.
* @returns {?string} Reason to end the collector, if any.
* @param {MessageReaction} reaction The reaction that was collected
* @param {User} user The user that reacted
* @returns {?string} Reason to end the collector, if any
* @private
*/
postCheck(reaction, user) {

View File

@@ -12,13 +12,13 @@ class ReactionEmoji {
this.reaction = reaction;
/**
* The name of this reaction emoji.
* The name of this reaction emoji
* @type {string}
*/
this.name = name;
/**
* The ID of this reaction emoji.
* The ID of this reaction emoji
* @type {?Snowflake}
*/
this.id = id;
@@ -37,7 +37,7 @@ class ReactionEmoji {
/**
* Creates the text required to form a graphical emoji on Discord.
* @example
* // send the emoji used in a reaction to the channel the reaction is part of
* // Send the emoji used in a reaction to the channel the reaction is part of
* reaction.message.channel.sendMessage(`The emoji used is ${reaction.emoji}`);
* @returns {string}
*/

View File

@@ -1,7 +1,7 @@
const ClientDataResolver = require('../client/ClientDataResolver');
/**
* A rich embed to be sent with a message with a fluent interface for creation
* A rich embed to be sent with a message with a fluent interface for creation.
* @param {Object} [data] Data to set in the rich embed
*/
class RichEmbed {
@@ -74,7 +74,7 @@ class RichEmbed {
}
/**
* Sets the title of this embed
* Sets the title of this embed.
* @param {StringResolvable} title The title
* @returns {RichEmbed} This embed
*/
@@ -86,7 +86,7 @@ class RichEmbed {
}
/**
* Sets the description of this embed
* Sets the description of this embed.
* @param {StringResolvable} description The description
* @returns {RichEmbed} This embed
*/
@@ -98,7 +98,7 @@ class RichEmbed {
}
/**
* Sets the URL of this embed
* Sets the URL of this embed.
* @param {string} url The URL
* @returns {RichEmbed} This embed
*/
@@ -108,7 +108,7 @@ class RichEmbed {
}
/**
* Sets the color of this embed
* Sets the color of this embed.
* @param {ColorResolvable} color The color of the embed
* @returns {RichEmbed} This embed
*/
@@ -118,7 +118,7 @@ class RichEmbed {
}
/**
* Sets the author of this embed
* Sets the author of this embed.
* @param {StringResolvable} name The name of the author
* @param {string} [icon] The icon URL of the author
* @param {string} [url] The URL of the author
@@ -130,7 +130,7 @@ class RichEmbed {
}
/**
* Sets the timestamp of this embed
* Sets the timestamp of this embed.
* @param {Date} [timestamp=current date] The timestamp
* @returns {RichEmbed} This embed
*/
@@ -140,7 +140,7 @@ class RichEmbed {
}
/**
* Adds a field to the embed (max 25)
* Adds a field to the embed (max 25).
* @param {StringResolvable} name The name of the field
* @param {StringResolvable} value The value of the field
* @param {boolean} [inline=false] Set the field to display inline
@@ -168,7 +168,7 @@ class RichEmbed {
}
/**
* Set the thumbnail of this embed
* Set the thumbnail of this embed.
* @param {string} url The URL of the thumbnail
* @returns {RichEmbed} This embed
*/
@@ -178,7 +178,7 @@ class RichEmbed {
}
/**
* Set the image of this embed
* Set the image of this embed.
* @param {string} url The URL of the image
* @returns {RichEmbed} This embed
*/
@@ -188,7 +188,7 @@ class RichEmbed {
}
/**
* Sets the footer of this embed
* Sets the footer of this embed.
* @param {StringResolvable} text The text of the footer
* @param {string} [icon] The icon URL of the footer
* @returns {RichEmbed} This embed

View File

@@ -3,7 +3,7 @@ const Permissions = require('../util/Permissions');
const util = require('util');
/**
* Represents a role on Discord
* Represents a role on Discord.
*/
class Role {
constructor(guild, data) {
@@ -93,7 +93,7 @@ class Role {
}
/**
* The hexadecimal version of the role color, with a leading hashtag.
* The hexadecimal version of the role color, with a leading hashtag
* @type {string}
* @readonly
*/
@@ -104,7 +104,7 @@ class Role {
}
/**
* The cached guild members that have this role.
* The cached guild members that have this role
* @type {Collection<Snowflake, GuildMember>}
* @readonly
*/
@@ -113,7 +113,7 @@ class Role {
}
/**
* Whether the role is editable by the client user.
* Whether the role is editable by the client user
* @type {boolean}
* @readonly
*/
@@ -138,7 +138,7 @@ class Role {
* Get an object mapping permission names to whether or not the role enables that permission
* @returns {Object<string, boolean>}
* @example
* // print the serialized role permissions
* // Print the serialized role permissions
* console.log(role.serialize());
*/
serialize() {
@@ -154,7 +154,7 @@ class Role {
* (takes priority over `explicit`)
* @returns {boolean}
* @example
* // see if a role can ban a member
* // See if a role can ban a member
* if (role.hasPermission('BAN_MEMBERS')) {
* console.log('This role can ban members');
* } else {
@@ -189,7 +189,7 @@ class Role {
}
/**
* The data for a role
* The data for a role.
* @typedef {Object} RoleData
* @property {string} [name] The name of the role
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
@@ -200,11 +200,11 @@ class Role {
*/
/**
* Edits the role
* Edits the role.
* @param {RoleData} data The new data for the role
* @returns {Promise<Role>}
* @example
* // edit a role
* // Edit a role
* role.edit({name: 'new role'})
* .then(r => console.log(`Edited role ${r}`))
* .catch(console.error);
@@ -214,11 +214,11 @@ class Role {
}
/**
* Set a new name for the role
* Set a new name for the role.
* @param {string} name The new name of the role
* @returns {Promise<Role>}
* @example
* // set the name of the role
* // Set the name of the role
* role.setName('new role')
* .then(r => console.log(`Edited name of role ${r}`))
* .catch(console.error);
@@ -228,11 +228,11 @@ class Role {
}
/**
* Set a new color for the role
* Set a new color for the role.
* @param {ColorResolvable} color The color of the role
* @returns {Promise<Role>}
* @example
* // set the color of a role
* // Set the color of a role
* role.setColor('#FF0000')
* .then(r => console.log(`Set color of role ${r}`))
* .catch(console.error);
@@ -242,11 +242,11 @@ class Role {
}
/**
* Set whether or not the role should be hoisted
* Set whether or not the role should be hoisted.
* @param {boolean} hoist Whether or not to hoist the role
* @returns {Promise<Role>}
* @example
* // set the hoist of the role
* // Set the hoist of the role
* role.setHoist(true)
* .then(r => console.log(`Role hoisted: ${r.hoist}`))
* .catch(console.error);
@@ -256,12 +256,12 @@ class Role {
}
/**
* Set the position of the role
* Set the position of the role.
* @param {number} position The position of the role
* @param {boolean} [relative=false] Move the position relative to its current value
* @returns {Promise<Role>}
* @example
* // set the position of the role
* // Set the position of the role
* role.setPosition(1)
* .then(r => console.log(`Role position: ${r.position}`))
* .catch(console.error);
@@ -271,11 +271,11 @@ class Role {
}
/**
* Set the permissions of the role
* Set the permissions of the role.
* @param {string[]} permissions The permissions of the role
* @returns {Promise<Role>}
* @example
* // set the permissions of the role
* // Set the permissions of the role
* role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS'])
* .then(r => console.log(`Role updated ${r}`))
* .catch(console.error);
@@ -285,11 +285,11 @@ class Role {
}
/**
* Set whether this role is mentionable
* Set whether this role is mentionable.
* @param {boolean} mentionable Whether this role should be mentionable
* @returns {Promise<Role>}
* @example
* // make the role mentionable
* // Make the role mentionable
* role.setMentionable(true)
* .then(r => console.log(`Role updated ${r}`))
* .catch(console.error);
@@ -299,10 +299,10 @@ class Role {
}
/**
* Deletes the role
* Deletes the role.
* @returns {Promise<Role>}
* @example
* // delete a role
* // Delete a role
* role.delete()
* .then(r => console.log(`Deleted role ${r}`))
* .catch(console.error);

View File

@@ -19,7 +19,7 @@ class TextChannel extends GuildChannel {
super.setup(data);
/**
* The topic of the text channel, if there is one.
* The topic of the text channel
* @type {?string}
*/
this.topic = data.topic;
@@ -28,7 +28,7 @@ class TextChannel extends GuildChannel {
}
/**
* A collection of members that can see this channel, mapped by their ID.
* A collection of members that can see this channel, mapped by their ID
* @type {Collection<Snowflake, GuildMember>}
* @readonly
*/
@@ -42,6 +42,15 @@ class TextChannel extends GuildChannel {
return members;
}
/**
* If the Discord considers this channel NSFW
* @type {boolean}
* @readonly
*/
get nsfw() {
return /^nsfw(-|$)/.test(this.name);
}
/**
* Fetch all webhooks for the channel.
* @returns {Promise<Collection<Snowflake, Webhook>>}
@@ -52,12 +61,12 @@ class TextChannel extends GuildChannel {
/**
* Create a webhook for the channel.
* @param {string} name The name of the webhook.
* @param {BufferResolvable|Base64Resolvable} avatar The avatar for the webhook.
* @returns {Promise<Webhook>} webhook The created webhook.
* @param {string} name The name of the webhook
* @param {BufferResolvable|Base64Resolvable} avatar The avatar for the webhook
* @returns {Promise<Webhook>} webhook The created webhook
* @example
* channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png')
* .then(webhook => console.log(`Created Webhook ${webhook}`))
* .then(webhook => console.log(`Created webhook ${webhook}`))
* .catch(console.error)
*/
createWebhook(name, avatar) {
@@ -72,15 +81,6 @@ class TextChannel extends GuildChannel {
});
}
/**
* If the Discord Client considers this channel NSFW
* @type {boolean}
* @readonly
*/
get nsfw() {
return /^nsfw(-|$)/.test(this.name);
}
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}

View File

@@ -10,9 +10,9 @@ const Snowflake = require('../util/Snowflake');
class User {
constructor(client, data) {
/**
* The Client that created the instance of the the User.
* The client that created the instance of the the user
* @name User#client
* @type {Client}
* @type {}
* @readonly
*/
Object.defineProperty(this, 'client', { value: client });
@@ -46,19 +46,19 @@ class User {
this.avatar = data.avatar;
/**
* Whether or not the user is a bot.
* Whether or not the user is a bot
* @type {boolean}
*/
this.bot = Boolean(data.bot);
/**
* The ID of the last message sent by the user, if one was sent.
* The ID of the last message sent by the user, if one was sent
* @type {?Snowflake}
*/
this.lastMessageID = null;
/**
* The Message object of the last message sent by the user, if one was sent.
* The Message object of the last message sent by the user, if one was sent
* @type {?Message}
*/
this.lastMessage = null;
@@ -103,7 +103,7 @@ class User {
}
/**
* A link to the user's avatar (if they have one, otherwise null)
* A link to the user's avatar
* @type {?string}
* @readonly
*/
@@ -133,7 +133,7 @@ class User {
}
/**
* The discord "tag" for this user
* The Discord "tag" for this user
* @type {string}
* @readonly
*/
@@ -191,7 +191,7 @@ class User {
}
/**
* Creates a DM channel between the client and the user
* Creates a DM channel between the client and the user.
* @returns {Promise<DMChannel>}
*/
createDM() {
@@ -207,7 +207,7 @@ class User {
}
/**
* Sends a friend request to the user
* Sends a friend request to the user.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<User>}
*/
@@ -216,7 +216,7 @@ class User {
}
/**
* Removes the user from your friends
* Removes the user from your friends.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<User>}
*/
@@ -225,7 +225,7 @@ class User {
}
/**
* Blocks the user
* Blocks the user.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<User>}
*/
@@ -234,7 +234,7 @@ class User {
}
/**
* Unblocks the user
* Unblocks the user.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<User>}
*/
@@ -243,7 +243,7 @@ class User {
}
/**
* Get the profile of the user
* Get the profile of the user.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<UserProfile>}
*/
@@ -252,7 +252,7 @@ class User {
}
/**
* Sets a note for the user
* Sets a note for the user.
* <warn>This is only available when using a user account.</warn>
* @param {string} note The note to set for the user
* @returns {Promise<User>}

View File

@@ -1,10 +1,10 @@
/**
* Represents a user connection (or "platform identity")
* Represents a user connection (or "platform identity").
*/
class UserConnection {
constructor(user, data) {
/**
* The user that owns the Connection
* The user that owns the connection
* @type {User}
*/
this.user = user;
@@ -14,7 +14,7 @@ class UserConnection {
setup(data) {
/**
* The type of the Connection
* The type of the connection
* @type {string}
*/
this.type = data.type;

View File

@@ -13,7 +13,7 @@ class UserProfile {
this.user = user;
/**
* The Client that created the instance of the the UserProfile.
* The client that created the instance of the the UserProfile.
* @name UserProfile#client
* @type {Client}
* @readonly
@@ -21,7 +21,7 @@ class UserProfile {
Object.defineProperty(this, 'client', { value: user.client });
/**
* Guilds that the client user and the user share
* The guilds that the client user and the user share
* @type {Collection<Snowflake, Guild>}
*/
this.mutualGuilds = new Collection();

View File

@@ -10,7 +10,7 @@ class VoiceChannel extends GuildChannel {
super(guild, data);
/**
* The members in this voice channel.
* The members in this voice channel
* @type {Collection<Snowflake, GuildMember>}
*/
this.members = new Collection();
@@ -76,11 +76,11 @@ class VoiceChannel extends GuildChannel {
}
/**
* Sets the bitrate of the channel
* Sets the bitrate of the channel.
* @param {number} bitrate The new bitrate
* @returns {Promise<VoiceChannel>}
* @example
* // set the bitrate of a voice channel
* // Set the bitrate of a voice channel
* voiceChannel.setBitrate(48000)
* .then(vc => console.log(`Set bitrate to ${vc.bitrate} for ${vc.name}`))
* .catch(console.error);
@@ -90,11 +90,11 @@ class VoiceChannel extends GuildChannel {
}
/**
* Sets the user limit of the channel
* Sets the user limit of the channel.
* @param {number} userLimit The new user limit
* @returns {Promise<VoiceChannel>}
* @example
* // set the user limit of a voice channel
* // Set the user limit of a voice channel
* voiceChannel.setUserLimit(42)
* .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
* .catch(console.error);
@@ -104,10 +104,10 @@ class VoiceChannel extends GuildChannel {
}
/**
* Attempts to join this voice channel
* Attempts to join this voice channel.
* @returns {Promise<VoiceConnection>}
* @example
* // join a voice channel
* // Join a voice channel
* voiceChannel.join()
* .then(connection => console.log('Connected!'))
* .catch(console.error);
@@ -118,9 +118,9 @@ class VoiceChannel extends GuildChannel {
}
/**
* Leaves this voice channel
* Leaves this voice channel.
* @example
* // leave a voice channel
* // Leave a voice channel
* voiceChannel.leave();
*/
leave() {

View File

@@ -1,10 +1,10 @@
/**
* Represents a Discord voice region for guilds
* Represents a Discord voice region for guilds.
*/
class VoiceRegion {
constructor(data) {
/**
* ID of the region
* The ID of the region
* @type {string}
*/
this.id = data.id;

View File

@@ -1,13 +1,13 @@
const path = require('path');
/**
* Represents a webhook
* Represents a webhook.
*/
class Webhook {
constructor(client, dataOrID, token) {
if (client) {
/**
* The Client that instantiated the Webhook
* The client that instantiated the webhook
* @name Webhook#client
* @type {Client}
* @readonly
@@ -70,7 +70,7 @@ class Webhook {
}
/**
* Options that can be passed into send, sendMessage, sendFile, sendEmbed, and sendCode
* Options that can be passed into send, sendMessage, sendFile, sendEmbed, and sendCode.
* @typedef {Object} WebhookMessageOptions
* @property {string} [username=this.name] Username override for the message
* @property {string} [avatarURL] Avatar URL override for the message
@@ -87,12 +87,12 @@ class Webhook {
*/
/**
* Send a message with this webhook
* @param {StringResolvable} content The content to send.
* @param {WebhookMessageOptions} [options={}] The options to provide.
* Send a message with this webhook.
* @param {StringResolvable} content The content to send
* @param {WebhookMessageOptions} [options={}] The options to provide
* @returns {Promise<Message|Message[]>}
* @example
* // send a message
* // Send a message
* webhook.send('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
@@ -127,11 +127,11 @@ class Webhook {
/**
* Send a message with this webhook
* @param {StringResolvable} content The content to send.
* @param {WebhookMessageOptions} [options={}] The options to provide.
* @param {StringResolvable} content The content to send
* @param {WebhookMessageOptions} [options={}] The options to provide
* @returns {Promise<Message|Message[]>}
* @example
* // send a message
* // Send a message
* webhook.sendMessage('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
@@ -141,7 +141,7 @@ class Webhook {
}
/**
* Send a file with this webhook
* Send a file with this webhook.
* @param {BufferResolvable} attachment The file to send
* @param {string} [name='file.jpg'] The name and extension of the file
* @param {StringResolvable} [content] Text message to send with the attachment
@@ -153,7 +153,7 @@ class Webhook {
}
/**
* Send a code block with this webhook
* Send a code block with this webhook.
* @param {string} lang Language for the code block
* @param {StringResolvable} content Content of the code block
* @param {WebhookMessageOptions} options The options to provide
@@ -164,11 +164,11 @@ class Webhook {
}
/**
* Send a raw slack message with this webhook
* @param {Object} body The raw body to send.
* Send a raw slack message with this webhook.
* @param {Object} body The raw body to send
* @returns {Promise}
* @example
* // send a slack message
* // Send a slack message
* webhook.sendSlackMessage({
* 'username': 'Wumpus',
* 'attachments': [{
@@ -186,8 +186,8 @@ class Webhook {
/**
* Edit the webhook.
* @param {string} name The new name for the Webhook
* @param {BufferResolvable} avatar The new avatar for the Webhook.
* @param {string} name The new name for the webhook
* @param {BufferResolvable} avatar The new avatar for the webhook
* @returns {Promise<Webhook>}
*/
edit(name = this.name, avatar) {
@@ -204,7 +204,7 @@ class Webhook {
}
/**
* Delete the webhook
* Delete the webhook.
* @returns {Promise}
*/
delete() {

View File

@@ -4,14 +4,14 @@ const EventEmitter = require('events').EventEmitter;
/**
* Filter to be applied to the collector.
* @typedef {Function} CollectorFilter
* @param {...*} args Any arguments received by the listener.
* @returns {boolean} To collect or not collect.
* @param {...*} args Any arguments received by the listener
* @returns {boolean} To collect or not collect
*/
/**
* Options to be applied to the collector.
* @typedef {Object} CollectorOptions
* @property {number} [time] How long to run the collector for.
* @property {number} [time] How long to run the collector for
*/
/**
@@ -23,7 +23,7 @@ class Collector extends EventEmitter {
super();
/**
* The client.
* The client
* @name Collector#client
* @type {Client}
* @readonly
@@ -31,39 +31,39 @@ class Collector extends EventEmitter {
Object.defineProperty(this, 'client', { value: client });
/**
* The filter applied to this collector.
* The filter applied to this collector
* @type {CollectorFilter}
*/
this.filter = filter;
/**
* The options of this collector.
* The options of this collector
* @type {CollectorOptions}
*/
this.options = options;
/**
* The items collected by this collector.
* The items collected by this collector
* @type {Collection}
*/
this.collected = new Collection();
/**
* Whether this collector has finished collecting.
* Whether this collector has finished collecting
* @type {boolean}
*/
this.ended = false;
/**
* Timeout for cleanup.
* Timeout for cleanup
* @type {?Timeout}
* @private
*/
this._timeout = null;
/**
* Call this to handle an event as a collectable element.
* Accepts any event data as parameters.
* Call this to handle an event as a collectable element
* Accepts any event data as parameters
* @type {Function}
* @private
*/
@@ -72,7 +72,7 @@ class Collector extends EventEmitter {
}
/**
* @param {...*} args The arguments emitted by the listener.
* @param {...*} args The arguments emitted by the listener
* @emits Collector#collect
* @private
*/
@@ -85,8 +85,8 @@ class Collector extends EventEmitter {
/**
* Emitted whenever an element is collected.
* @event Collector#collect
* @param {*} element The element that got collected.
* @param {Collector} collector The collector.
* @param {*} element The element that got collected
* @param {Collector} collector The collector
*/
this.emit('collect', collect.value, this);
@@ -96,7 +96,7 @@ class Collector extends EventEmitter {
/**
* Return a promise that resolves with the next collected element;
* rejects with collected elements if the collector finishes without receving a next element.
* rejects with collected elements if the collector finishes without receving a next element
* @type {Promise}
* @readonly
*/
@@ -129,7 +129,7 @@ class Collector extends EventEmitter {
/**
* Stop this collector and emit the `end` event.
* @param {string} [reason='user'] The reason this collector is ending.
* @param {string} [reason='user'] The reason this collector is ending
* @emits Collector#end
*/
stop(reason = 'user') {
@@ -142,27 +142,27 @@ class Collector extends EventEmitter {
/**
* Emitted when the collector is finished collecting.
* @event Collector#end
* @param {Collection} collected The elements collected by the collector.
* @param {string} reason The reason the collector ended.
* @param {Collection} collected The elements collected by the collector
* @param {string} reason The reason the collector ended
*/
this.emit('end', this.collected, reason);
}
/* eslint-disable no-empty-function, valid-jsdoc */
/**
* Handles incoming events from the `listener` function. Returns null if the
* event should not be collected, or returns an object describing the data that should be stored.
* Handles incoming events from the `listener` function. Returns null if the event should not be collected,
* or returns an object describing the data that should be stored.
* @see Collector#listener
* @param {...*} args Any args the event listener emits.
* @returns {?{key: string, value}} Data to insert into collection, if any.
* @param {...*} args Any args the event listener emits
* @returns {?{key: string, value}} Data to insert into collection, if any
* @abstract
*/
handle() {}
/**
* This method runs after collection to see if the collector should finish.
* @param {...*} args Any args the event listener emits.
* @returns {?string} Reason to end the collector, if any.
* @param {...*} args Any args the event listener emits
* @returns {?string} Reason to end the collector, if any
* @abstract
*/
postCheck() {}

View File

@@ -5,32 +5,32 @@ const Collection = require('../../util/Collection');
const util = require('util');
/**
* Interface for classes that have text-channel-like features
* Interface for classes that have text-channel-like features.
* @interface
*/
class TextBasedChannel {
constructor() {
/**
* A collection containing the messages sent to this channel.
* A collection containing the messages sent to this channel
* @type {Collection<Snowflake, Message>}
*/
this.messages = new Collection();
/**
* The ID of the last message in the channel, if one was sent.
* The ID of the last message in the channel, if one was sent
* @type {?Snowflake}
*/
this.lastMessageID = null;
/**
* The Message object of the last message in the channel, if one was sent.
* The Message object of the last message in the channel, if one was sent
* @type {?Message}
*/
this.lastMessage = null;
}
/**
* Options provided when sending or editing a message
* Options provided when sending or editing a message.
* @typedef {Object} MessageOptions
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
* @property {string} [nonce=''] The nonce for the message
@@ -42,7 +42,7 @@ class TextBasedChannel {
* @property {FileOptions[]|string[]} [files] Files to send with the message
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
* it exceeds the character limit. If an object is provided, these are the options for splitting the message.
* it exceeds the character limit. If an object is provided, these are the options for splitting the message
* @property {UserResolvable} [reply] User to reply to (prefixes the message with a mention, except in DMs)
*/
@@ -53,7 +53,7 @@ class TextBasedChannel {
*/
/**
* Options for splitting a message
* Options for splitting a message.
* @typedef {Object} SplitOptions
* @property {number} [maxLength=1950] Maximum character length per message piece
* @property {string} [char='\n'] Character to split the message with
@@ -62,12 +62,12 @@ class TextBasedChannel {
*/
/**
* Send a message to this channel
* Send a message to this channel.
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options={}] Options for the message
* @returns {Promise<Message|Message[]>}
* @example
* // send a message
* // Send a message
* channel.send('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
@@ -121,7 +121,7 @@ class TextBasedChannel {
* @param {Snowflake} messageID ID of the message to get
* @returns {Promise<Message>}
* @example
* // get message
* // Get message
* channel.fetchMessage('99539446449315840')
* .then(message => console.log(message.content))
* .catch(console.error);
@@ -156,7 +156,7 @@ class TextBasedChannel {
* @param {ChannelLogsQueryOptions} [options={}] Query parameters to pass in
* @returns {Promise<Collection<Snowflake, Message>>}
* @example
* // get messages
* // Get messages
* channel.fetchMessages({limit: 10})
* .then(messages => console.log(`Received ${messages.size} messages`))
* .catch(console.error);
@@ -221,8 +221,8 @@ class TextBasedChannel {
* <warn>This is only available when using a user account.</warn>
* @param {MessageSearchOptions} [options={}] Options to pass to the search
* @returns {Promise<Array<Message[]>>}
* An array containing arrays of messages. Each inner array is a search context cluster.
* The message which has triggered the result will have the `hit` property set to `true`.
* An array containing arrays of messages. Each inner array is a search context cluster
* The message which has triggered the result will have the `hit` property set to `true`
* @example
* channel.search({
* content: 'discord.js',
@@ -240,7 +240,7 @@ class TextBasedChannel {
* Starts a typing indicator in the channel.
* @param {number} [count] The number of times startTyping should be considered to have been called
* @example
* // start typing in a channel
* // Start typing in a channel
* channel.startTyping();
*/
startTyping(count) {
@@ -265,10 +265,10 @@ class TextBasedChannel {
* <info>It can take a few seconds for the client user to stop typing.</info>
* @param {boolean} [force=false] Whether or not to reset the call count and force the indicator to stop
* @example
* // stop typing in a channel
* // Stop typing in a channel
* channel.stopTyping();
* @example
* // force typing to fully stop in a channel
* // Force typing to fully stop in a channel
* channel.stopTyping(true);
*/
stopTyping(force = false) {
@@ -283,7 +283,7 @@ class TextBasedChannel {
}
/**
* Whether or not the typing indicator is being shown in the channel.
* Whether or not the typing indicator is being shown in the channel
* @type {boolean}
* @readonly
*/
@@ -292,7 +292,7 @@ class TextBasedChannel {
}
/**
* Number of times `startTyping` has been called.
* Number of times `startTyping` has been called
* @type {number}
* @readonly
*/
@@ -313,12 +313,12 @@ class TextBasedChannel {
}
/**
* Creates a Message Collector
* Creates a Message Collector.
* @param {CollectorFilter} filter The filter to create the collector with
* @param {MessageCollectorOptions} [options={}] The options to pass to the collector
* @returns {MessageCollector}
* @example
* // create a message collector
* // Create a message collector
* const collector = channel.createCollector(
* m => m.content.includes('discord'),
* { time: 15000 }
@@ -343,9 +343,9 @@ class TextBasedChannel {
* @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector
* @returns {Promise<Collection<Snowflake, Message>>}
* @example
* // await !vote messages
* // Await !vote messages
* const filter = m => m.content.startsWith('!vote');
* // errors: ['time'] treats ending because of the time limit as an error
* // Errors: ['time'] treats ending because of the time limit as an error
* channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
* .then(collected => console.log(collected.size))
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
@@ -364,7 +364,7 @@ class TextBasedChannel {
}
/**
* Bulk delete given messages that are newer than two weeks
* Bulk delete given messages that are newer than two weeks.
* <warn>This is only available when using a bot account.</warn>
* @param {Collection<Snowflake, Message>|Message[]|number} messages Messages or number of messages to delete
* @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically
@@ -380,7 +380,7 @@ class TextBasedChannel {
}
/**
* Marks all messages in this channel as read
* Marks all messages in this channel as read.
* <warn>This is only available when using a user account.</warn>
* @returns {Promise<TextChannel|GroupDMChannel|DMChannel>}
*/
@@ -401,13 +401,13 @@ class TextBasedChannel {
/** @lends TextBasedChannel.prototype */
const Deprecated = {
/**
* Send a message to this channel
* Send a message to this channel.
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options={}] Options for the message
* @returns {Promise<Message|Message[]>}
* @deprecated
* @example
* // send a message
* // Send a message
* channel.sendMessage('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
@@ -417,7 +417,7 @@ const Deprecated = {
},
/**
* Send an embed to this channel
* Send an embed to this channel.
* @param {RichEmbed|Object} embed Embed for the message
* @param {string} [content] Text for the message
* @param {MessageOptions} [options] Options for the message
@@ -435,7 +435,7 @@ const Deprecated = {
},
/**
* Send files to this channel
* Send files to this channel.
* @param {FileOptions[]|string[]} files Files to send with the message
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options] Options for the message
@@ -447,7 +447,7 @@ const Deprecated = {
},
/**
* Send a file to this channel
* Send a file to this channel.
* @param {BufferResolvable} attachment File to send
* @param {string} [name='file.jpg'] Name and extension of the file
* @param {StringResolvable} [content] Text for the message
@@ -460,7 +460,7 @@ const Deprecated = {
},
/**
* Send a code block to this channel
* Send a code block to this channel.
* @param {string} lang Language for the code block
* @param {StringResolvable} content Content of the code block
* @param {MessageOptions} [options] Options for the message

View File

@@ -8,7 +8,7 @@ class Collection extends Map {
super(iterable);
/**
* Cached array for the `array()` method - will be reset to `null` whenever `set()` or `delete()` are called.
* Cached array for the `array()` method - will be reset to `null` whenever `set()` or `delete()` are called
* @name Collection#_array
* @type {?Array}
* @private
@@ -16,7 +16,7 @@ class Collection extends Map {
Object.defineProperty(this, '_array', { value: null, writable: true, configurable: true });
/**
* Cached array for the `keyArray()` method - will be reset to `null` whenever `set()` or `delete()` are called.
* Cached array for the `keyArray()` method - will be reset to `null` whenever `set()` or `delete()` are called
* @name Collection#_keyArray
* @type {?Array}
* @private

View File

@@ -1,7 +1,7 @@
exports.Package = require('../../package.json');
/**
* Options for a Client.
* Options for a client.
* @typedef {Object} ClientOptions
* @property {string} [apiRequestMethod='sequential'] One of `sequential` or `burst`. The sequential handler executes
* all requests in the order they are triggered, whereas the burst handler runs multiple in parallel, and doesn't
@@ -28,7 +28,7 @@ exports.Package = require('../../package.json');
* processed, potentially resulting in performance improvements for larger bots. Only disable events you are
* 100% certain you don't need, as many are important, but not obviously so. The safest one to disable with the
* most impact is typically `TYPING_START`.
* @property {WebsocketOptions} [ws] Options for the websocket
* @property {WebsocketOptions} [ws] Options for the WebSocket
*/
exports.DefaultOptions = {
apiRequestMethod: 'sequential',
@@ -45,7 +45,7 @@ exports.DefaultOptions = {
restTimeOffset: 500,
/**
* Websocket options (these are left as snake_case to match the API)
* WebSocket options (these are left as snake_case to match the API)
* @typedef {Object} WebsocketOptions
* @property {number} [large_threshold=250] Number of members in a guild to be considered large
* @property {boolean} [compress=true] Whether to compress data sent on the connection
@@ -436,7 +436,7 @@ exports.ExplicitContentFilterTypes = [
exports.UserSettingsMap = {
/**
* Automatically convert emoticons in your messages to emoji.
* Automatically convert emoticons in your messages to emoji
* For example, when you type `:-)` Discord will convert it to 😃
* @name ClientUserSettings#convertEmoticons
* @type {boolean}

View File

@@ -5,7 +5,7 @@ const EPOCH = 1420070400000;
let INCREMENT = 0;
/**
* A container for useful snowflake-related methods
* A container for useful snowflake-related methods.
*/
class SnowflakeUtil {
constructor() {
@@ -19,13 +19,13 @@ class SnowflakeUtil {
*
* 64 22 17 12 0
* 000000111011000111100001101001000101000000 00001 00000 000000000000
* number of ms since discord epoch worker pid increment
* number of ms since Discord epoch worker pid increment
* ```
* @typedef {string} Snowflake
*/
/**
* Generates a Discord snowflake
* Generates a Discord snowflake.
* <info>This hardcodes the worker ID as 1 and the process ID as 0.</info>
* @returns {Snowflake} The generated snowflake
*/
@@ -36,7 +36,7 @@ class SnowflakeUtil {
}
/**
* A deconstructed snowflake
* A deconstructed snowflake.
* @typedef {Object} DeconstructedSnowflake
* @property {number} timestamp Timestamp the snowflake was created
* @property {Date} date Date the snowflake was created
@@ -47,7 +47,7 @@ class SnowflakeUtil {
*/
/**
* Deconstructs a Discord snowflake
* Deconstructs a Discord snowflake.
* @param {Snowflake} snowflake Snowflake to deconstruct
* @returns {DeconstructedSnowflake} Deconstructed snowflake
*/

View File

@@ -50,7 +50,7 @@ class Util {
* Gets the recommended shard count from Discord.
* @param {string} token Discord auth token
* @param {number} [guildsPerShard=1000] Number of guilds per shard
* @returns {Promise<number>} the recommended number of shards
* @returns {Promise<number>} The recommended number of shards
*/
static fetchRecommendedShards(token, guildsPerShard = 1000) {
return new Promise((resolve, reject) => {
@@ -90,7 +90,7 @@ class Util {
* Checks whether the arrays are equal, also removes duplicated entries from b.
* @param {Array<*>} a Array which will not be modified.
* @param {Array<*>} b Array to remove duplicated entries from.
* @returns {boolean} boolean Whether the arrays are equal.
* @returns {boolean} Whether the arrays are equal.
* @private
*/
static arraysEqual(a, b) {
@@ -160,7 +160,7 @@ class Util {
}
/**
* Makes an Error from a plain info object
* Makes an Error from a plain info object.
* @param {Object} obj Error info
* @param {string} obj.name Error type
* @param {string} obj.message Message for the error
@@ -176,7 +176,7 @@ class Util {
}
/**
* Makes a plain error info object from an Error
* Makes a plain error info object from an Error.
* @param {Error} err Error to get info from
* @returns {Object}
* @private
@@ -190,7 +190,7 @@ class Util {
}
/**
* Moves an element in an array *in place*
* Moves an element in an array *in place*.
* @param {Array<*>} array Array to modify
* @param {*} element Element to move
* @param {number} newIndex Index or offset to move the element to