Docs cleanup

This commit is contained in:
iCrawl
2017-08-17 20:04:01 +02:00
parent 5ce0def9d0
commit 2aa2f73c74
40 changed files with 366 additions and 359 deletions

View File

@@ -19,11 +19,7 @@ client.on('ready', () => {
// Create an event listener for new guild members // Create an event listener for new guild members
client.on('guildMemberAdd', member => { client.on('guildMemberAdd', member => {
// Send the message to the guilds default channel (usually #general), mentioning the member // Send the message to a designated channel on a server:
member.guild.defaultChannel.send(`Welcome to the server, ${member}!`);
// If you want to send the message to a designated channel on a server instead
// you can do the following:
const channel = member.guild.channels.find('name', 'member-log'); const channel = member.guild.channels.find('name', 'member-log');
// Do nothing if the channel wasn't found on this server // Do nothing if the channel wasn't found on this server
if (!channel) return; if (!channel) return;

View File

@@ -29,7 +29,7 @@ class ClientDataResolver {
/** /**
* Data that resolves to give a User object. This can be: * Data that resolves to give a User object. This can be:
* * A User object * * A User object
* * A user ID * * A Snowflake
* * A Message object (resolves to the message author) * * A Message object (resolves to the message author)
* * A Guild object (owner of the guild) * * A Guild object (owner of the guild)
* * A GuildMember object * * A GuildMember object
@@ -66,7 +66,7 @@ class ClientDataResolver {
/** /**
* Data that resolves to give a Guild object. This can be: * Data that resolves to give a Guild object. This can be:
* * A Guild object * * A Guild object
* * A Guild ID * * A Snowflake
* @typedef {Guild|Snowflake} GuildResolvable * @typedef {Guild|Snowflake} GuildResolvable
*/ */
@@ -128,7 +128,7 @@ class ClientDataResolver {
* * A Channel object * * A Channel object
* * A Message object (the channel the message was sent in) * * A Message object (the channel the message was sent in)
* * A Guild object (the #general channel) * * A Guild object (the #general channel)
* * A channel ID * * A Snowflake
* @typedef {Channel|Guild|Message|Snowflake} ChannelResolvable * @typedef {Channel|Guild|Message|Snowflake} ChannelResolvable
*/ */

View File

@@ -18,7 +18,7 @@ const ffmpegArguments = [
* ```js * ```js
* const broadcast = client.createVoiceBroadcast(); * const broadcast = client.createVoiceBroadcast();
* broadcast.playFile('./music.mp3'); * broadcast.playFile('./music.mp3');
* // play "music.mp3" in all voice connections that the client is in * // Play "music.mp3" in all voice connections that the client is in
* for (const connection of client.voiceConnections.values()) { * for (const connection of client.voiceConnections.values()) {
* connection.playBroadcast(broadcast); * connection.playBroadcast(broadcast);
* } * }
@@ -141,12 +141,12 @@ class VoiceBroadcast extends VolumeInterface {
* const broadcast = client.createVoiceBroadcast(); * const broadcast = client.createVoiceBroadcast();
* *
* voiceChannel.join() * voiceChannel.join()
* .then(connection => { * .then(connection => {
* const stream = ytdl('https://www.youtube.com/watch?v=XAWgeLF9EVQ', { filter : 'audioonly' }); * const stream = ytdl('https://www.youtube.com/watch?v=XAWgeLF9EVQ', { filter : 'audioonly' });
* broadcast.playStream(stream); * broadcast.playStream(stream);
* const dispatcher = connection.playBroadcast(broadcast); * const dispatcher = connection.playBroadcast(broadcast);
* }) * })
* .catch(console.error); * .catch(console.error);
*/ */
playStream(stream, options = {}) { playStream(stream, options = {}) {
this.setVolume(options.volume || 1); this.setVolume(options.volume || 1);
@@ -163,11 +163,11 @@ class VoiceBroadcast extends VolumeInterface {
* const broadcast = client.createVoiceBroadcast(); * const broadcast = client.createVoiceBroadcast();
* *
* voiceChannel.join() * voiceChannel.join()
* .then(connection => { * .then(connection => {
* broadcast.playFile('C:/Users/Discord/Desktop/music.mp3'); * broadcast.playFile('C:/Users/Discord/Desktop/music.mp3');
* const dispatcher = connection.playBroadcast(broadcast); * const dispatcher = connection.playBroadcast(broadcast);
* }) * })
* .catch(console.error); * .catch(console.error);
*/ */
playFile(file, options = {}) { playFile(file, options = {}) {
this.setVolume(options.volume || 1); this.setVolume(options.volume || 1);

View File

@@ -12,9 +12,10 @@ const { Error } = require('../../errors');
* Represents a connection to a guild's voice server. * Represents a connection to a guild's voice server.
* ```js * ```js
* // Obtained using: * // Obtained using:
* voiceChannel.join().then(connection => { * voiceChannel.join()
* .then(connection => {
* *
* }); * });
* ``` * ```
* @extends {EventEmitter} * @extends {EventEmitter}
*/ */
@@ -311,7 +312,7 @@ class VoiceConnection extends EventEmitter {
} }
/** /**
* Internally disconnects (doesn't send disconnect packet.) * Internally disconnects (doesn't send disconnect packet).
* @private * @private
*/ */
_disconnect() { _disconnect() {
@@ -454,10 +455,10 @@ class VoiceConnection extends EventEmitter {
* @example * @example
* // Play files natively * // Play files natively
* voiceChannel.join() * voiceChannel.join()
* .then(connection => { * .then(connection => {
* const dispatcher = connection.playFile('C:/Users/Discord/Desktop/music.mp3'); * const dispatcher = connection.playFile('C:/Users/Discord/Desktop/music.mp3');
* }) * })
* .catch(console.error); * .catch(console.error);
*/ */
playFile(file, options) { playFile(file, options) {
return this.player.playUnknownStream(`file:${file}`, options); return this.player.playUnknownStream(`file:${file}`, options);
@@ -483,11 +484,11 @@ class VoiceConnection extends EventEmitter {
* const ytdl = require('ytdl-core'); * const ytdl = require('ytdl-core');
* const streamOptions = { seek: 0, volume: 1 }; * const streamOptions = { seek: 0, volume: 1 };
* voiceChannel.join() * voiceChannel.join()
* .then(connection => { * .then(connection => {
* const stream = ytdl('https://www.youtube.com/watch?v=XAWgeLF9EVQ', { filter : 'audioonly' }); * const stream = ytdl('https://www.youtube.com/watch?v=XAWgeLF9EVQ', { filter : 'audioonly' });
* const dispatcher = connection.playStream(stream, streamOptions); * const dispatcher = connection.playStream(stream, streamOptions);
* }) * })
* .catch(console.error); * .catch(console.error);
*/ */
playStream(stream, options) { playStream(stream, options) {
return this.player.playUnknownStream(stream, options); return this.player.playUnknownStream(stream, options);
@@ -531,7 +532,8 @@ class VoiceConnection extends EventEmitter {
} }
/** /**
* Creates a VoiceReceiver so you can start listening to voice data. It's recommended to only create one of these. * Creates a VoiceReceiver so you can start listening to voice data.
* It's recommended to only create one of these.
* @returns {VoiceReceiver} * @returns {VoiceReceiver}
*/ */
createReceiver() { createReceiver() {

View File

@@ -89,12 +89,12 @@ class StreamDispatcher extends VolumeInterface {
} }
/** /**
* Stops sending voice packets to the voice connection (stream may still progress however) * Stops sending voice packets to the voice connection (stream may still progress however).
*/ */
pause() { this.setPaused(true); } pause() { this.setPaused(true); }
/** /**
* Resumes sending voice packets to the voice connection (may be further on in the stream than when paused) * Resumes sending voice packets to the voice connection (may be further on in the stream than when paused).
*/ */
resume() { this.setPaused(false); } resume() { this.setPaused(false); }
@@ -122,7 +122,7 @@ class StreamDispatcher extends VolumeInterface {
/** /**
* Set the bitrate of the current Opus encoder. * Set the bitrate of the current Opus encoder.
* @param {number} bitrate New bitrate, in kbps. * @param {number} bitrate New bitrate, in kbps
* If set to 'auto', the voice channel's bitrate will be used * If set to 'auto', the voice channel's bitrate will be used
*/ */
setBitrate(bitrate) { setBitrate(bitrate) {
@@ -140,7 +140,7 @@ class StreamDispatcher extends VolumeInterface {
/** /**
* Emitted whenever the dispatcher has debug information. * Emitted whenever the dispatcher has debug information.
* @event StreamDispatcher#debug * @event StreamDispatcher#debug
* @param {string} info the debug info * @param {string} info The debug info
*/ */
this.setSpeaking(true); this.setSpeaking(true);
while (repeats--) { while (repeats--) {
@@ -294,7 +294,7 @@ class StreamDispatcher extends VolumeInterface {
this.emit(type, reason); this.emit(type, reason);
/** /**
* Emitted once the dispatcher ends. * Emitted once the dispatcher ends.
* @param {string} [reason] the reason the dispatcher ended * @param {string} [reason] The reason the dispatcher ended
* @event StreamDispatcher#end * @event StreamDispatcher#end
*/ */
if (type !== 'end') this.emit('end', `destroyed due to ${type} - ${reason}`); if (type !== 'end') this.emit('end', `destroyed due to ${type} - ${reason}`);

View File

@@ -4,10 +4,10 @@
*/ */
class BaseOpus { class BaseOpus {
/** /**
* @param {Object} [options] The options to apply to the Opus engine. * @param {Object} [options] The options to apply to the Opus engine
* @param {number} [options.bitrate=48] The desired bitrate (kbps). * @param {number} [options.bitrate=48] The desired bitrate (kbps)
* @param {boolean} [options.fec=false] Whether to enable forward error correction. * @param {boolean} [options.fec=false] Whether to enable forward error correction
* @param {number} [options.plp=0] The expected packet loss percentage. * @param {number} [options.plp=0] The expected packet loss percentage
*/ */
constructor({ bitrate = 48, fec = false, plp = 0 } = {}) { constructor({ bitrate = 48, fec = false, plp = 0 } = {}) {
this.ctl = { this.ctl = {

View File

@@ -83,7 +83,7 @@ class AudioPlayer extends EventEmitter {
/** /**
* Set the bitrate of the current Opus encoder. * Set the bitrate of the current Opus encoder.
* @param {number} value New bitrate, in kbps. * @param {number} value New bitrate, in kbps
* If set to 'auto', the voice channel's bitrate will be used * If set to 'auto', the voice channel's bitrate will be used
*/ */
setBitrate(value) { setBitrate(value) {

View File

@@ -11,9 +11,10 @@ nonce.fill(0);
* Receives voice data from a voice connection. * Receives voice data from a voice connection.
* ```js * ```js
* // Obtained using: * // Obtained using:
* voiceChannel.join().then(connection => { * voiceChannel.join()
* const receiver = connection.createReceiver(); * .then(connection => {
* }); * const receiver = connection.createReceiver();
* });
* ``` * ```
* @extends {EventEmitter} * @extends {EventEmitter}
*/ */

View File

@@ -29,12 +29,12 @@ const WebSocket = (function findWebSocket() {
class WebSocketConnection extends EventEmitter { class WebSocketConnection extends EventEmitter {
/** /**
* @param {WebSocketManager} manager The WebSocket manager * @param {WebSocketManager} manager The WebSocket manager
* @param {string} gateway WebSocket gateway to connect to * @param {string} gateway The WebSocket gateway to connect to
*/ */
constructor(manager, gateway) { constructor(manager, gateway) {
super(); super();
/** /**
* WebSocket Manager of this connection * The WebSocket Manager of this connection
* @type {WebSocketManager} * @type {WebSocketManager}
*/ */
this.manager = manager; this.manager = manager;
@@ -233,7 +233,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 {string} gateway The gateway to connect to
* @param {number} [after=0] How long to wait before connecting * @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 * @param {boolean} [force=false] Whether or not to force a new connection even if one already exists
* @returns {boolean} * @returns {boolean}
@@ -358,7 +358,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 * @param {Error} error The error that occurred
*/ */
onError(error) { onError(error) {
if (error && error.message === 'uWs client connection error') { if (error && error.message === 'uWs client connection error') {

View File

@@ -3,7 +3,7 @@ const Constants = require('../../util/Constants');
const WebSocketConnection = require('./WebSocketConnection'); const WebSocketConnection = require('./WebSocketConnection');
/** /**
* WebSocket Manager of the client * WebSocket Manager of the client.
* @private * @private
*/ */
class WebSocketManager extends EventEmitter { class WebSocketManager extends EventEmitter {
@@ -23,7 +23,7 @@ class WebSocketManager extends EventEmitter {
} }
/** /**
* Sends a heartbeat on the available connection * Sends a heartbeat on the available connection.
* @returns {void} * @returns {void}
*/ */
heartbeat() { heartbeat() {
@@ -67,7 +67,7 @@ class WebSocketManager extends EventEmitter {
/** /**
* Connects the client to a gateway. * Connects the client to a gateway.
* @param {string} gateway Gateway to connect to * @param {string} gateway The gateway to connect to
* @returns {boolean} * @returns {boolean}
*/ */
connect(gateway) { connect(gateway) {

View File

@@ -6,7 +6,7 @@ const assert = require('assert');
const util = require('util'); const util = require('util');
/** /**
* Extend an error of some sort into a DiscordjsError * Extend an error of some sort into a DiscordjsError.
* @param {Error} Base Base error to extend * @param {Error} Base Base error to extend
* @returns {DiscordjsError} * @returns {DiscordjsError}
*/ */
@@ -29,7 +29,7 @@ function makeDiscordjsError(Base) {
} }
/** /**
* Format the message for an error * Format the message for an error.
* @param {string} key Error key * @param {string} key Error key
* @param {Array<*>} args Arguments to pass for util format or as function args * @param {Array<*>} args Arguments to pass for util format or as function args
* @returns {string} Formatted string * @returns {string} Formatted string
@@ -49,7 +49,7 @@ function message(key, args) {
} }
/** /**
* Register an error code and message * Register an error code and message.
* @param {string} sym Unique name for the error * @param {string} sym Unique name for the error
* @param {*} val Value of the error * @param {*} val Value of the error
*/ */

View File

@@ -70,9 +70,11 @@ class Shard {
* @param {string} prop Name of the client property to get, using periods for nesting * @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<*>} * @returns {Promise<*>}
* @example * @example
* shard.fetchClientValue('guilds.size').then(count => { * shard.fetchClientValue('guilds.size')
* console.log(`${count} guilds in shard ${shard.id}`); * .then(count => {
* }).catch(console.error); * console.log(`${count} guilds in shard ${shard.id}`);
* })
* .catch(console.error);
*/ */
fetchClientValue(prop) { fetchClientValue(prop) {
if (this._fetches.has(prop)) return this._fetches.get(prop); if (this._fetches.has(prop)) return this._fetches.get(prop);

View File

@@ -50,9 +50,11 @@ class ShardClientUtil {
* @param {string} prop Name of the client property to get, using periods for nesting * @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<Array>} * @returns {Promise<Array>}
* @example * @example
* client.shard.fetchClientValues('guilds.size').then(results => { * client.shard.fetchClientValues('guilds.size')
* console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`); * .then(results => {
* }).catch(console.error); * console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`);
* })
* .catch(console.error);
*/ */
fetchClientValues(prop) { fetchClientValues(prop) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@@ -181,9 +181,11 @@ class ShardingManager extends EventEmitter {
* @param {string} prop Name of the client property to get, using periods for nesting * @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<Array>} * @returns {Promise<Array>}
* @example * @example
* manager.fetchClientValues('guilds.size').then(results => { * manager.fetchClientValues('guilds.size')
* console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`); * .then(results => {
* }).catch(console.error); * console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`);
* })
* .catch(console.error);
*/ */
fetchClientValues(prop) { fetchClientValues(prop) {
if (this.shards.size === 0) return Promise.reject(new Error('SHARDING_NO_SHARDS')); if (this.shards.size === 0) return Promise.reject(new Error('SHARDING_NO_SHARDS'));

View File

@@ -1,5 +1,5 @@
/** /**
* Represents an attachment in a message * Represents an attachment in a message.
*/ */
class Attachment { class Attachment {
constructor(file, name) { constructor(file, name) {

View File

@@ -61,8 +61,8 @@ class Channel {
* @example * @example
* // Delete the channel * // Delete the channel
* channel.delete() * channel.delete()
* .then() // Success * .then() // Success
* .catch(console.error); // Log error * .catch(console.error); // Log error
*/ */
delete() { delete() {
return this.client.api.channels(this.id).delete().then(() => this); return this.client.api.channels(this.id).delete().then(() => this);

View File

@@ -124,7 +124,7 @@ class ClientApplication {
} }
/** /**
* A link to the application's icon * A link to the application's icon.
* @param {Object} [options={}] Options for the icon url * @param {Object} [options={}] Options for the icon url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`
@@ -136,7 +136,7 @@ class ClientApplication {
} }
/** /**
* A link to this application's cover image * A link to this application's cover image.
* @param {Object} [options={}] Options for the cover image url * @param {Object} [options={}] Options for the cover image url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`
@@ -150,7 +150,7 @@ class ClientApplication {
} }
/** /**
* Get rich presence assets * Get rich presence assets.
* @returns {Promise<Object>} * @returns {Promise<Object>}
*/ */
fetchAssets() { fetchAssets() {
@@ -163,7 +163,7 @@ class ClientApplication {
} }
/** /**
* Create a rich presence asset * Create a rich presence asset.
* @param {string} name Name of the asset * @param {string} name Name of the asset
* @param {Base64Resolvable} data Data of the asset * @param {Base64Resolvable} data Data of the asset
* @param {string} type Type of the asset. `big`, or `small` * @param {string} type Type of the asset. `big`, or `small`

View File

@@ -83,7 +83,7 @@ class ClientUser extends User {
/** /**
* All of the user's guild settings * All of the user's guild settings
* @type {Collection<Snowflake, ClientUserGuildSettings>} * @type {Collection<Snowflake, ClientUserGuildSettings>}
* <warn>This is only filled when using a user account</warn> * <warn>This is only filled when using a user account.</warn>
*/ */
this.guildSettings = new Collection(); this.guildSettings = new Collection();
if (data.user_guild_settings) { if (data.user_guild_settings) {
@@ -119,8 +119,8 @@ class ClientUser extends User {
* @example * @example
* // Set username * // Set username
* client.user.setUsername('discordjs') * client.user.setUsername('discordjs')
* .then(user => console.log(`My new username is ${user.username}`)) * .then(user => console.log(`My new username is ${user.username}`))
* .catch(console.error); * .catch(console.error);
*/ */
setUsername(username, password) { setUsername(username, password) {
return this.edit({ username }, password); return this.edit({ username }, password);
@@ -135,8 +135,8 @@ class ClientUser extends User {
* @example * @example
* // Set email * // Set email
* client.user.setEmail('bob@gmail.com', 'some amazing password 123') * client.user.setEmail('bob@gmail.com', 'some amazing password 123')
* .then(user => console.log(`My new email is ${user.email}`)) * .then(user => console.log(`My new email is ${user.email}`))
* .catch(console.error); * .catch(console.error);
*/ */
setEmail(email, password) { setEmail(email, password) {
return this.edit({ email }, password); return this.edit({ email }, password);
@@ -154,8 +154,8 @@ class ClientUser extends User {
* @example * @example
* // Set password * // Set password
* client.user.setPassword('some new amazing password 456', 'some amazing password 123') * client.user.setPassword('some new amazing password 456', 'some amazing password 123')
* .then(user => console.log('New password set!')) * .then(user => console.log('New password set!'))
* .catch(console.error); * .catch(console.error);
*/ */
setPassword(newPassword, options) { setPassword(newPassword, options) {
return this.edit({ new_password: newPassword }, { password: options.oldPassword, mfaCode: options.mfaCode }); return this.edit({ new_password: newPassword }, { password: options.oldPassword, mfaCode: options.mfaCode });
@@ -168,8 +168,8 @@ class ClientUser extends User {
* @example * @example
* // Set avatar * // Set avatar
* client.user.setAvatar('./avatar.png') * client.user.setAvatar('./avatar.png')
* .then(user => console.log(`New avatar set!`)) * .then(user => console.log(`New avatar set!`))
* .catch(console.error); * .catch(console.error);
*/ */
setAvatar(avatar) { setAvatar(avatar) {
if (typeof avatar === 'string' && avatar.startsWith('data:')) { if (typeof avatar === 'string' && avatar.startsWith('data:')) {
@@ -253,10 +253,10 @@ class ClientUser extends User {
/** /**
* A user's status. Must be one of: * A user's status. Must be one of:
* - `online` * * `online`
* - `idle` * * `idle`
* - `invisible` * * `invisible`
* - `dnd` (do not disturb) * * `dnd` (do not disturb)
* @typedef {string} PresenceStatus * @typedef {string} PresenceStatus
*/ */

View File

@@ -115,10 +115,10 @@ class Emoji {
* @param {string} [reason] Reason for editing this emoji * @param {string} [reason] Reason for editing this emoji
* @returns {Promise<Emoji>} * @returns {Promise<Emoji>}
* @example * @example
* // Edit a emoji * // Edit an emoji
* emoji.edit({name: 'newemoji'}) * emoji.edit({name: 'newemoji'})
* .then(e => console.log(`Edited emoji ${e}`)) * .then(e => console.log(`Edited emoji ${e}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data, reason) {
return this.client.api.guilds(this.guild.id).emojis(this.id) return this.client.api.guilds(this.guild.id).emojis(this.id)

View File

@@ -106,7 +106,7 @@ class GroupDMChannel extends Channel {
} }
/** /**
* Gets the URL to this Group DM's icon * Gets the URL to this Group DM's icon.
* @param {Object} [options={}] Options for the icon url * @param {Object} [options={}] Options for the icon url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`

View File

@@ -220,7 +220,8 @@ class Guild {
if (!this.emojis) { if (!this.emojis) {
/** /**
* A collection of emojis that are in this guild. The key is the emoji's ID, the value is the emoji. * A collection of emojis that are in this guild
* The key is the emoji's ID, the value is the emoji
* @type {Collection<Snowflake, Emoji>} * @type {Collection<Snowflake, Emoji>}
*/ */
this.emojis = new Collection(); this.emojis = new Collection();
@@ -261,7 +262,7 @@ class Guild {
} }
/** /**
* Gets the URL to this guild's icon * The URL to this guild's icon.
* @param {Object} [options={}] Options for the icon url * @param {Object} [options={}] Options for the icon url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`
@@ -273,7 +274,7 @@ class Guild {
} }
/** /**
* Gets the acronym that shows up in place of a guild icon * The acronym that shows up in place of a guild icon.
* @type {string} * @type {string}
* @readonly * @readonly
*/ */
@@ -282,7 +283,7 @@ class Guild {
} }
/** /**
* The URL to this guild's splash * The URL to this guild's splash.
* @param {Object} [options={}] Options for the splash url * @param {Object} [options={}] Options for the splash url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg` * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048` * @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`
@@ -443,7 +444,8 @@ class Guild {
} }
/** /**
* Fetch a collection of invites to this guild. Resolves with a collection mapping invites by their codes. * Fetch a collection of invites to this guild.
* Resolves with a collection mapping invites by their codes.
* @returns {Promise<Collection<string, Invite>>} * @returns {Promise<Collection<string, Invite>>}
*/ */
fetchInvites() { fetchInvites() {
@@ -566,7 +568,7 @@ class Guild {
fetchMembers({ query = '', limit = 0 } = {}) { fetchMembers({ query = '', limit = 0 } = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.memberCount === this.members.size) { if (this.memberCount === this.members.size) {
resolve((query || limit) ? new Collection() : this.members); resolve(query || limit ? new Collection() : this.members);
return; return;
} }
this.client.ws.send({ this.client.ws.send({
@@ -585,7 +587,7 @@ class Guild {
} }
if (this.memberCount === this.members.size || ((query || limit) && members.size < 1000)) { if (this.memberCount === this.members.size || ((query || limit) && members.size < 1000)) {
this.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler); this.client.removeListener(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
resolve((query || limit) ? fetchedMembers : this.members); resolve(query || limit ? fetchedMembers : this.members);
} }
}; };
this.client.on(Constants.Events.GUILD_MEMBERS_CHUNK, handler); this.client.on(Constants.Events.GUILD_MEMBERS_CHUNK, handler);
@@ -636,11 +638,11 @@ class Guild {
* @example * @example
* // Set the guild name and region * // Set the guild name and region
* guild.edit({ * guild.edit({
* name: 'Discord Guild', * name: 'Discord Guild',
* region: 'london', * region: 'london',
* }) * })
* .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`)) * .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data, reason) {
const _data = {}; const _data = {};
@@ -841,8 +843,8 @@ class Guild {
* @example * @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') * guild.ban('some user ID')
* .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`)) * .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
ban(user, options = { days: 0 }) { ban(user, options = { days: 0 }) {
if (options.days) options['delete-message-days'] = options.days; if (options.days) options['delete-message-days'] = options.days;
@@ -868,8 +870,8 @@ class Guild {
* @example * @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') * guild.unban('some user ID')
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`)) * .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
unban(user, reason) { unban(user, reason) {
const id = this.client.resolver.resolveUserID(user); const id = this.client.resolver.resolveUserID(user);
@@ -929,8 +931,8 @@ class Guild {
* @example * @example
* // Create a new text channel * // Create a new text channel
* guild.createChannel('new-general', 'text') * guild.createChannel('new-general', 'text')
* .then(channel => console.log(`Created new channel ${channel}`)) * .then(channel => console.log(`Created new channel ${channel}`))
* .catch(console.error); * .catch(console.error);
*/ */
createChannel(name, type, { overwrites, reason } = {}) { createChannel(name, type, { overwrites, reason } = {}) {
if (overwrites instanceof Collection || overwrites instanceof Array) { if (overwrites instanceof Collection || overwrites instanceof Array) {
@@ -981,8 +983,8 @@ class Guild {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
* @example * @example
* guild.updateChannels([{ channel: channelID, position: newChannelIndex }]) * guild.updateChannels([{ channel: channelID, position: newChannelIndex }])
* .then(guild => console.log(`Updated channel positions for ${guild.id}`)) * .then(guild => console.log(`Updated channel positions for ${guild.id}`))
* .catch(console.error); * .catch(console.error);
*/ */
setChannelPositions(channelPositions) { setChannelPositions(channelPositions) {
const data = new Array(channelPositions.length); const data = new Array(channelPositions.length);
@@ -1013,8 +1015,8 @@ class Guild {
* @example * @example
* // Create a new role * // Create a new role
* guild.createRole() * guild.createRole()
* .then(role => console.log(`Created role ${role}`)) * .then(role => console.log(`Created role ${role}`))
* .catch(console.error); * .catch(console.error);
* @example * @example
* // Create a new role with data and a reason * // Create a new role with data and a reason
* guild.createRole({ * guild.createRole({
@@ -1024,8 +1026,8 @@ class Guild {
* }, * },
* reason: 'we needed a role for Super Cool People', * reason: 'we needed a role for Super Cool People',
* }) * })
* .then(role => console.log(`Created role ${role}`)) * .then(role => console.log(`Created role ${role}`))
* .catch(console.error) * .catch(console.error)
*/ */
createRole({ data = {}, reason } = {}) { createRole({ data = {}, reason } = {}) {
if (data.color) data.color = Util.resolveColor(data.color); if (data.color) data.color = Util.resolveColor(data.color);
@@ -1050,13 +1052,13 @@ class Guild {
* @example * @example
* // Create a new emoji from a url * // Create a new emoji from a url
* guild.createEmoji('https://i.imgur.com/w3duR07.png', 'rip') * guild.createEmoji('https://i.imgur.com/w3duR07.png', 'rip')
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error); * .catch(console.error);
* @example * @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') * guild.createEmoji('./memes/banana.png', 'banana')
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error); * .catch(console.error);
*/ */
createEmoji(attachment, name, { roles, reason } = {}) { createEmoji(attachment, name, { roles, reason } = {}) {
if (typeof attachment === 'string' && attachment.startsWith('data:')) { if (typeof attachment === 'string' && attachment.startsWith('data:')) {
@@ -1102,8 +1104,8 @@ class Guild {
* @example * @example
* // Leave a guild * // Leave a guild
* guild.leave() * guild.leave()
* .then(g => console.log(`Left the guild ${g}`)) * .then(g => console.log(`Left the guild ${g}`))
* .catch(console.error); * .catch(console.error);
*/ */
leave() { leave() {
if (this.ownerID === this.client.user.id) return Promise.reject(new Error('GUILD_OWNED')); if (this.ownerID === this.client.user.id) return Promise.reject(new Error('GUILD_OWNED'));
@@ -1117,8 +1119,8 @@ class Guild {
* @example * @example
* // Delete a guild * // Delete a guild
* guild.delete() * guild.delete()
* .then(g => console.log(`Deleted the guild ${g}`)) * .then(g => console.log(`Deleted the guild ${g}`))
* .catch(console.error); * .catch(console.error);
*/ */
delete() { delete() {
return this.client.api.guilds(this.id).delete() return this.client.api.guilds(this.id).delete()

View File

@@ -184,7 +184,7 @@ class GuildAuditLogsEntry {
this.executor = guild.client.users.get(data.user_id); this.executor = guild.client.users.get(data.user_id);
/** /**
* An entry in the audit log representing a specific change * An entry in the audit log representing a specific change.
* @typedef {object} AuditLogChange * @typedef {object} AuditLogChange
* @property {string} key The property that was changed, e.g. `nick` for nickname changes * @property {string} key The property that was changed, e.g. `nick` for nickname changes
* @property {*} [old] The old value of the change, e.g. for nicknames, the old nickname * @property {*} [old] The old value of the change, e.g. for nicknames, the old nickname

View File

@@ -146,10 +146,10 @@ class GuildChannel extends Channel {
* @example * @example
* // Overwrite permissions for a message author * // Overwrite permissions for a message author
* message.channel.overwritePermissions(message.author, { * message.channel.overwritePermissions(message.author, {
* SEND_MESSAGES: false * SEND_MESSAGES: false
* }) * })
* .then(() => console.log('Done!')) * .then(() => console.log('Done!'))
* .catch(console.error); * .catch(console.error);
*/ */
overwritePermissions(userOrRole, options, reason) { overwritePermissions(userOrRole, options, reason) {
const payload = { const payload = {
@@ -228,8 +228,8 @@ class GuildChannel extends Channel {
* @example * @example
* // Edit a channel * // Edit a channel
* channel.edit({name: 'new-channel'}) * channel.edit({name: 'new-channel'})
* .then(c => console.log(`Edited channel ${c}`)) * .then(c => console.log(`Edited channel ${c}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data, reason) {
return this.client.api.channels(this.id).patch({ return this.client.api.channels(this.id).patch({
@@ -252,8 +252,8 @@ class GuildChannel extends Channel {
* @example * @example
* // Set a new channel name * // Set a new channel name
* channel.setName('not_general') * channel.setName('not_general')
* .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`)) * .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name }, reason);
@@ -267,8 +267,8 @@ class GuildChannel extends Channel {
* @example * @example
* // Set a new channel position * // Set a new channel position
* channel.setPosition(2) * channel.setPosition(2)
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`)) * .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
* .catch(console.error); * .catch(console.error);
*/ */
setPosition(position, relative) { setPosition(position, relative) {
return this.guild.setChannelPosition(this, position, relative).then(() => this); return this.guild.setChannelPosition(this, position, relative).then(() => this);
@@ -282,8 +282,8 @@ class GuildChannel extends Channel {
* @example * @example
* // Set a new channel topic * // Set a new channel topic
* channel.setTopic('needs more rate limiting') * channel.setTopic('needs more rate limiting')
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`)) * .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
* .catch(console.error); * .catch(console.error);
*/ */
setTopic(topic, reason) { setTopic(topic, reason) {
return this.edit({ topic }, reason); return this.edit({ topic }, reason);
@@ -366,8 +366,8 @@ class GuildChannel extends Channel {
* @example * @example
* // Delete the channel * // Delete the channel
* channel.delete('making room for new channels') * channel.delete('making room for new channels')
* .then() // Success * .then() // Success
* .catch(console.error); // Log error * .catch(console.error); // Log error
*/ */
delete(reason) { delete(reason) {
return this.client.api.channels(this.id).delete({ reason }).then(() => this); return this.client.api.channels(this.id).delete({ reason }).then(() => this);

View File

@@ -503,7 +503,7 @@ class GuildMember {
} }
/** /**
* Ban this guild member * Ban this guild member.
* @param {Object|number|string} [options] Ban options. If a number, the number of days to delete messages for, if a * @param {Object|number|string} [options] Ban options. If a number, the number of days to delete messages for, if a
* string, the ban reason. Supplying an object allows you to do both. * string, the ban reason. Supplying an object allows you to do both.
* @param {number} [options.days=0] Number of days of messages to delete * @param {number} [options.days=0] Number of days of messages to delete

View File

@@ -59,8 +59,8 @@ class Message {
this.author = this.client.dataManager.newUser(data.author); this.author = this.client.dataManager.newUser(data.author);
/** /**
* Represents the author of the message as a guild member. Only available if the message comes from a guild * Represents the author of the message as a guild member
* where the author is still a member. * Only available if the message comes from a guild where the author is still a member
* @type {?GuildMember} * @type {?GuildMember}
*/ */
this.member = this.guild ? this.guild.member(this.author) || null : null; this.member = this.guild ? this.guild.member(this.author) || null : null;
@@ -226,8 +226,8 @@ class Message {
} }
/** /**
* The message contents with all mentions replaced by the equivalent text. If mentions cannot be resolved to a name, * The message contents with all mentions replaced by the equivalent text.
* the relevant mention in the message content will not be converted * If mentions cannot be resolved to a name, the relevant mention in the message content will not be converted.
* @type {string} * @type {string}
* @readonly * @readonly
*/ */
@@ -271,8 +271,8 @@ class Message {
* @example * @example
* // Create a reaction collector * // Create a reaction collector
* const collector = message.createReactionCollector( * const collector = message.createReactionCollector(
* (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someID', * (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someID',
* { time: 15000 } * { time: 15000 }
* ); * );
* collector.on('collect', r => console.log(`Collected ${r.emoji.name}`)); * collector.on('collect', r => console.log(`Collected ${r.emoji.name}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
@@ -288,8 +288,8 @@ class Message {
*/ */
/** /**
* Similar to createCollector but in promise form. Resolves with a collection of reactions that pass the specified * Similar to createCollector but in promise form.
* filter. * Resolves with a collection of reactions that pass the specified filter.
* @param {CollectorFilter} filter The filter function to use * @param {CollectorFilter} filter The filter function to use
* @param {AwaitReactionsOptions} [options={}] Optional options to pass to the internal collector * @param {AwaitReactionsOptions} [options={}] Optional options to pass to the internal collector
* @returns {Promise<Collection<string, MessageReaction>>} * @returns {Promise<Collection<string, MessageReaction>>}
@@ -362,8 +362,8 @@ class Message {
* @example * @example
* // Update the content of a message * // Update the content of a message
* message.edit('This is my new content!') * message.edit('This is my new content!')
* .then(msg => console.log(`Updated the content of a message from ${msg.author}`)) * .then(msg => console.log(`Updated the content of a message from ${msg.author}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(content, options) { edit(content, options) {
if (!options && typeof content === 'object' && !(content instanceof Array)) { if (!options && typeof content === 'object' && !(content instanceof Array)) {
@@ -448,8 +448,8 @@ class Message {
* @example * @example
* // Delete a message * // Delete a message
* message.delete() * message.delete()
* .then(msg => console.log(`Deleted message from ${msg.author}`)) * .then(msg => console.log(`Deleted message from ${msg.author}`))
* .catch(console.error); * .catch(console.error);
*/ */
delete({ timeout = 0, reason } = {}) { delete({ timeout = 0, reason } = {}) {
if (timeout <= 0) { if (timeout <= 0) {
@@ -477,8 +477,8 @@ class Message {
* @example * @example
* // Reply to a message * // Reply to a message
* message.reply('Hey, I\'m a reply!') * message.reply('Hey, I\'m a reply!')
* .then(msg => console.log(`Sent a reply to ${msg.author}`)) * .then(msg => console.log(`Sent a reply to ${msg.author}`))
* .catch(console.error); * .catch(console.error);
*/ */
reply(content, options) { reply(content, options) {
if (!options && typeof content === 'object' && !(content instanceof Array)) { if (!options && typeof content === 'object' && !(content instanceof Array)) {

View File

@@ -21,7 +21,8 @@ class MessageCollector extends Collector {
super(channel.client, filter, options); super(channel.client, filter, options);
/** /**
* @type {TextBasedChannel} channel The channel * The channel
* @type {TextBasedChannel}
*/ */
this.channel = channel; this.channel = channel;
@@ -49,7 +50,7 @@ class MessageCollector extends Collector {
/** /**
* Handle a message for possible collection. * Handle a message for possible collection.
* @param {Message} message The message that could be collected * @param {Message} message The message that could be collected
* @returns {?{key: Snowflake, value: Message}} Message data to collect * @returns {?{key: Snowflake, value: Message}}
* @private * @private
*/ */
collect(message) { collect(message) {
@@ -64,7 +65,7 @@ class MessageCollector extends Collector {
/** /**
* Handle a message for possible disposal. * Handle a message for possible disposal.
* @param {Message} message The message that could be disposed * @param {Message} message The message that could be disposed
* @returns {?string} The message ID. * @returns {?string}
*/ */
dispose(message) { dispose(message) {
return message.channel.id === this.channel.id ? message.id : null; return message.channel.id === this.channel.id ? message.id : null;
@@ -72,7 +73,7 @@ class MessageCollector extends Collector {
/** /**
* Check after un/collection to see if the collector is done. * Check after un/collection to see if the collector is done.
* @returns {?string} Reason to end the collector, if any * @returns {?string}
* @private * @private
*/ */
endReason() { endReason() {

View File

@@ -57,7 +57,7 @@ class MessageEmbed {
this.fields = data.fields || []; this.fields = data.fields || [];
/** /**
* The thumbnail of this embed, if there is one * The thumbnail of this embed (if there is one)
* @type {?Object} * @type {?Object}
* @property {string} url URL for this thumbnail * @property {string} url URL for this thumbnail
* @property {string} proxyURL ProxyURL for this thumbnail * @property {string} proxyURL ProxyURL for this thumbnail
@@ -87,7 +87,7 @@ class MessageEmbed {
} : null; } : null;
/** /**
* The video of this embed, if there is one * The video of this embed (if there is one)
* @type {?Object} * @type {?Object}
* @property {string} url URL of this video * @property {string} url URL of this video
* @property {number} height Height of this video * @property {number} height Height of this video
@@ -96,7 +96,7 @@ class MessageEmbed {
this.video = data.video; this.video = data.video;
/** /**
* The author of this embed, if there is one * The author of this embed (if there is one)
* @type {?Object} * @type {?Object}
* @property {string} name The name of this author * @property {string} name The name of this author
* @property {string} url URL of this author * @property {string} url URL of this author
@@ -111,7 +111,7 @@ class MessageEmbed {
} : null; } : null;
/** /**
* The provider of this embed, if there is one * The provider of this embed (if there is one)
* @type {?Object} * @type {?Object}
* @property {string} name The name of this provider * @property {string} name The name of this provider
* @property {string} url URL of this provider * @property {string} url URL of this provider
@@ -132,14 +132,12 @@ class MessageEmbed {
} : null; } : null;
/** /**
* The files of this embed * The files of this embed
* @type {?Object} * @type {?Object}
* @property {Array<FileOptions|string|Attachment>} files Files to attach * @property {Array<FileOptions|string|Attachment>} files Files to attach
*/ */
if (data.files) { if (data.files) {
for (let file of data.files) { for (let file of data.files) if (file instanceof Attachment) file = file.file;
if (file instanceof Attachment) file = file.file;
}
} else { data.files = null; } } else { data.files = null; }
} }
@@ -166,7 +164,7 @@ class MessageEmbed {
* @param {StringResolvable} name The name of the field * @param {StringResolvable} name The name of the field
* @param {StringResolvable} value The value of the field * @param {StringResolvable} value The value of the field
* @param {boolean} [inline=false] Set the field to display inline * @param {boolean} [inline=false] Set the field to display inline
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
addField(name, value, inline = false) { addField(name, value, inline = false) {
if (this.fields.length >= 25) throw new RangeError('EMBED_FIELD_COUNT'); if (this.fields.length >= 25) throw new RangeError('EMBED_FIELD_COUNT');
@@ -181,7 +179,7 @@ class MessageEmbed {
/** /**
* Convenience function for `<MessageEmbed>.addField('\u200B', '\u200B', inline)`. * Convenience function for `<MessageEmbed>.addField('\u200B', '\u200B', inline)`.
* @param {boolean} [inline=false] Set the field to display inline * @param {boolean} [inline=false] Set the field to display inline
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
addBlankField(inline = false) { addBlankField(inline = false) {
return this.addField('\u200B', '\u200B', inline); return this.addField('\u200B', '\u200B', inline);
@@ -191,7 +189,7 @@ class MessageEmbed {
* Sets the file to upload alongside the embed. This file can be accessed via `attachment://fileName.extension` when * Sets the file to upload alongside the embed. This file can be accessed via `attachment://fileName.extension` when
* setting an embed image or author/footer icons. Only one file may be attached. * setting an embed image or author/footer icons. Only one file may be attached.
* @param {Array<FileOptions|string|Attachment>} files Files to attach * @param {Array<FileOptions|string|Attachment>} files Files to attach
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
attachFiles(files) { attachFiles(files) {
if (this.files) this.files = this.files.concat(files); if (this.files) this.files = this.files.concat(files);
@@ -207,7 +205,7 @@ class MessageEmbed {
* @param {StringResolvable} name The name of the author * @param {StringResolvable} name The name of the author
* @param {string} [iconURL] The icon URL of the author * @param {string} [iconURL] The icon URL of the author
* @param {string} [url] The URL of the author * @param {string} [url] The URL of the author
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setAuthor(name, iconURL, url) { setAuthor(name, iconURL, url) {
this.author = { name: Util.resolveString(name), iconURL, url }; this.author = { name: Util.resolveString(name), iconURL, url };
@@ -217,7 +215,7 @@ class MessageEmbed {
/** /**
* Sets the color of this embed. * Sets the color of this embed.
* @param {ColorResolvable} color The color of the embed * @param {ColorResolvable} color The color of the embed
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setColor(color) { setColor(color) {
this.color = Util.resolveColor(color); this.color = Util.resolveColor(color);
@@ -227,7 +225,7 @@ class MessageEmbed {
/** /**
* Sets the description of this embed. * Sets the description of this embed.
* @param {StringResolvable} description The description * @param {StringResolvable} description The description
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setDescription(description) { setDescription(description) {
description = Util.resolveString(description); description = Util.resolveString(description);
@@ -240,7 +238,7 @@ class MessageEmbed {
* Sets the footer of this embed. * Sets the footer of this embed.
* @param {StringResolvable} text The text of the footer * @param {StringResolvable} text The text of the footer
* @param {string} [iconURL] The icon URL of the footer * @param {string} [iconURL] The icon URL of the footer
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setFooter(text, iconURL) { setFooter(text, iconURL) {
text = Util.resolveString(text); text = Util.resolveString(text);
@@ -252,7 +250,7 @@ class MessageEmbed {
/** /**
* Set the image of this embed. * Set the image of this embed.
* @param {string} url The URL of the image * @param {string} url The URL of the image
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setImage(url) { setImage(url) {
this.image = { url }; this.image = { url };
@@ -262,7 +260,7 @@ class MessageEmbed {
/** /**
* Set the thumbnail of this embed. * Set the thumbnail of this embed.
* @param {string} url The URL of the thumbnail * @param {string} url The URL of the thumbnail
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setThumbnail(url) { setThumbnail(url) {
this.thumbnail = { url }; this.thumbnail = { url };
@@ -272,7 +270,7 @@ class MessageEmbed {
/** /**
* Sets the timestamp of this embed. * Sets the timestamp of this embed.
* @param {Date} [timestamp=current date] The timestamp * @param {Date} [timestamp=current date] The timestamp
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setTimestamp(timestamp = new Date()) { setTimestamp(timestamp = new Date()) {
this.timestamp = timestamp.getTime(); this.timestamp = timestamp.getTime();
@@ -282,7 +280,7 @@ class MessageEmbed {
/** /**
* Sets the title of this embed. * Sets the title of this embed.
* @param {StringResolvable} title The title * @param {StringResolvable} title The title
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setTitle(title) { setTitle(title) {
title = Util.resolveString(title); title = Util.resolveString(title);
@@ -294,7 +292,7 @@ class MessageEmbed {
/** /**
* Sets the URL of this embed. * Sets the URL of this embed.
* @param {string} url The URL * @param {string} url The URL
* @returns {MessageEmbed} This embed * @returns {MessageEmbed}
*/ */
setURL(url) { setURL(url) {
this.url = url; this.url = url;

View File

@@ -118,8 +118,8 @@ class MessageMentions {
} }
/** /**
* Check if a user is mentioned. Takes into account user mentions, role * Check if a user is mentioned.
* mentions, and @everyone/@here mentions. * Takes into account user mentions, role mentions, and @everyone/@here mentions.
* @param {UserResolvable|GuildMember|Role|GuildChannel} data User/GuildMember/Role/Channel to check * @param {UserResolvable|GuildMember|Role|GuildChannel} data User/GuildMember/Role/Channel to check
* @param {boolean} [strict=true] If role mentions and everyone/here mentions should be included * @param {boolean} [strict=true] If role mentions and everyone/here mentions should be included
* @returns {boolean} * @returns {boolean}

View File

@@ -67,7 +67,7 @@ class Game {
} }
/** /**
* Whether this game is equal to another game * Whether this game is equal to another game.
* @param {Game} game The game to compare with * @param {Game} game The game to compare with
* @returns {boolean} * @returns {boolean}
*/ */

View File

@@ -65,7 +65,7 @@ class ReactionCollector extends Collector {
/** /**
* Handle an incoming reaction for possible collection. * Handle an incoming reaction for possible collection.
* @param {MessageReaction} reaction The reaction to possibly collect * @param {MessageReaction} reaction The reaction to possibly collect
* @returns {?{key: Snowflake, value: MessageReaction}} Reaction data to collect * @returns {?{key: Snowflake, value: MessageReaction}}
* @private * @private
*/ */
collect(reaction) { collect(reaction) {
@@ -79,7 +79,7 @@ class ReactionCollector extends Collector {
/** /**
* Handle a reaction deletion for possible disposal. * Handle a reaction deletion for possible disposal.
* @param {MessageReaction} reaction The reaction to possibly dispose * @param {MessageReaction} reaction The reaction to possibly dispose
* @returns {?Snowflake|string} The reaction key * @returns {?Snowflake|string}
*/ */
dispose(reaction) { dispose(reaction) {
return reaction.message.id === this.message.id && !reaction.count ? ReactionCollector.key(reaction) : null; return reaction.message.id === this.message.id && !reaction.count ? ReactionCollector.key(reaction) : null;
@@ -105,7 +105,7 @@ class ReactionCollector extends Collector {
/** /**
* Get the collector key for a reaction. * Get the collector key for a reaction.
* @param {MessageReaction} reaction The message reaction to get the key for * @param {MessageReaction} reaction The message reaction to get the key for
* @returns {Snowflake|string} The emoji ID (if custom) or the emoji name (if native; will be unicode) * @returns {Snowflake|string}
*/ */
static key(reaction) { static key(reaction) {
return reaction.emoji.id || reaction.emoji.name; return reaction.emoji.id || reaction.emoji.name;

View File

@@ -135,7 +135,7 @@ class Role {
} }
/** /**
* Get an object mapping permission names to whether or not the role enables that permission * Get an object mapping permission names to whether or not the role enables that permission.
* @returns {Object<string, boolean>} * @returns {Object<string, boolean>}
* @example * @example
* // Print the serialized role permissions * // Print the serialized role permissions
@@ -198,8 +198,8 @@ class Role {
* @example * @example
* // Edit a role * // Edit a role
* role.edit({name: 'new role'}) * role.edit({name: 'new role'})
* .then(r => console.log(`Edited role ${r}`)) * .then(r => console.log(`Edited role ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data, reason) {
if (data.permissions) data.permissions = Permissions.resolve(data.permissions); if (data.permissions) data.permissions = Permissions.resolve(data.permissions);
@@ -226,8 +226,8 @@ class Role {
* @example * @example
* // Set the name of the role * // Set the name of the role
* role.setName('new role') * role.setName('new role')
* .then(r => console.log(`Edited name of role ${r}`)) * .then(r => console.log(`Edited name of role ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name }, reason);
@@ -241,8 +241,8 @@ class Role {
* @example * @example
* // Set the color of a role * // Set the color of a role
* role.setColor('#FF0000') * role.setColor('#FF0000')
* .then(r => console.log(`Set color of role ${r}`)) * .then(r => console.log(`Set color of role ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
setColor(color, reason) { setColor(color, reason) {
return this.edit({ color }, reason); return this.edit({ color }, reason);
@@ -256,8 +256,8 @@ class Role {
* @example * @example
* // Set the hoist of the role * // Set the hoist of the role
* role.setHoist(true) * role.setHoist(true)
* .then(r => console.log(`Role hoisted: ${r.hoist}`)) * .then(r => console.log(`Role hoisted: ${r.hoist}`))
* .catch(console.error); * .catch(console.error);
*/ */
setHoist(hoist, reason) { setHoist(hoist, reason) {
return this.edit({ hoist }, reason); return this.edit({ hoist }, reason);
@@ -271,8 +271,8 @@ class Role {
* @example * @example
* // Set the position of the role * // Set the position of the role
* role.setPosition(1) * role.setPosition(1)
* .then(r => console.log(`Role position: ${r.position}`)) * .then(r => console.log(`Role position: ${r.position}`))
* .catch(console.error); * .catch(console.error);
*/ */
setPosition(position, relative) { setPosition(position, relative) {
return this.guild.setRolePosition(this, position, relative).then(() => this); return this.guild.setRolePosition(this, position, relative).then(() => this);
@@ -286,8 +286,8 @@ class Role {
* @example * @example
* // Set the permissions of the role * // Set the permissions of the role
* role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS']) * role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS'])
* .then(r => console.log(`Role updated ${r}`)) * .then(r => console.log(`Role updated ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
setPermissions(permissions, reason) { setPermissions(permissions, reason) {
return this.edit({ permissions }, reason); return this.edit({ permissions }, reason);
@@ -301,8 +301,8 @@ class Role {
* @example * @example
* // Make the role mentionable * // Make the role mentionable
* role.setMentionable(true) * role.setMentionable(true)
* .then(r => console.log(`Role updated ${r}`)) * .then(r => console.log(`Role updated ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
setMentionable(mentionable, reason) { setMentionable(mentionable, reason) {
return this.edit({ mentionable }, reason); return this.edit({ mentionable }, reason);
@@ -315,8 +315,8 @@ class Role {
* @example * @example
* // Delete a role * // Delete a role
* role.delete() * role.delete()
* .then(r => console.log(`Deleted role ${r}`)) * .then(r => console.log(`Deleted role ${r}`))
* .catch(console.error); * .catch(console.error);
*/ */
delete(reason) { delete(reason) {
return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason }) return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason })

View File

@@ -54,9 +54,9 @@ class TextChannel extends GuildChannel {
* @param {string} [reason] Reason for creating this webhook * @param {string} [reason] Reason for creating this webhook
* @returns {Promise<Webhook>} webhook The created webhook * @returns {Promise<Webhook>} webhook The created webhook
* @example * @example
* channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png') * channel.createWebhook('Snek', 'https://i.imgur.com/mI8XcpG.jpg')
* .then(webhook => console.log(`Created webhook ${webhook}`)) * .then(webhook => console.log(`Created webhook ${webhook}`))
* .catch(console.error) * .catch(console.error)
*/ */
createWebhook(name, avatar, reason) { createWebhook(name, avatar, reason) {
if (typeof avatar === 'string' && avatar.startsWith('data:')) { if (typeof avatar === 'string' && avatar.startsWith('data:')) {

View File

@@ -105,7 +105,7 @@ class User {
} }
/** /**
* A link to the user's avatar * A link to the user's avatar.
* @param {Object} [options={}] Options for the avatar url * @param {Object} [options={}] Options for the avatar url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided,
* it will be `gif` for animated avatars or otherwise `webp` * it will be `gif` for animated avatars or otherwise `webp`
@@ -127,7 +127,8 @@ class User {
} }
/** /**
* A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned * A link to the user's avatar if they have one.
* Otherwise a link to their default avatar will be returned.
* @param {Object} [options={}] Options for the avatar url * @param {Object} [options={}] Options for the avatar url
* @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, * @param {string} [options.format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided,
* it will be `gif` for animated avatars or otherwise `webp` * it will be `gif` for animated avatars or otherwise `webp`

View File

@@ -14,7 +14,7 @@ class UserProfile {
this.user = user; this.user = user;
/** /**
* The client that created the instance of the UserProfile. * The client that created the instance of the UserProfile
* @name UserProfile#client * @name UserProfile#client
* @type {Client} * @type {Client}
* @readonly * @readonly

View File

@@ -82,8 +82,8 @@ class VoiceChannel extends GuildChannel {
* @example * @example
* // Set the bitrate of a voice channel * // Set the bitrate of a voice channel
* voiceChannel.setBitrate(48) * voiceChannel.setBitrate(48)
* .then(vc => console.log(`Set bitrate to ${vc.bitrate}kbps for ${vc.name}`)) * .then(vc => console.log(`Set bitrate to ${vc.bitrate}kbps for ${vc.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
setBitrate(bitrate, reason) { setBitrate(bitrate, reason) {
bitrate *= 1000; bitrate *= 1000;
@@ -98,8 +98,8 @@ class VoiceChannel extends GuildChannel {
* @example * @example
* // Set the user limit of a voice channel * // Set the user limit of a voice channel
* voiceChannel.setUserLimit(42) * voiceChannel.setUserLimit(42)
* .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`)) * .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
setUserLimit(userLimit, reason) { setUserLimit(userLimit, reason) {
return this.edit({ userLimit }, reason); return this.edit({ userLimit }, reason);
@@ -111,8 +111,8 @@ class VoiceChannel extends GuildChannel {
* @example * @example
* // Join a voice channel * // Join a voice channel
* voiceChannel.join() * voiceChannel.join()
* .then(connection => console.log('Connected!')) * .then(connection => console.log('Connected!'))
* .catch(console.error); * .catch(console.error);
*/ */
join() { join() {
if (this.client.browser) return Promise.reject(new Error('VOICE_NO_BROWSER')); if (this.client.browser) return Promise.reject(new Error('VOICE_NO_BROWSER'));

View File

@@ -99,8 +99,8 @@ class Webhook {
* @example * @example
* // Send a message * // Send a message
* webhook.send('hello!') * webhook.send('hello!')
* .then(message => console.log(`Sent message: ${message.content}`)) * .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error); * .catch(console.error);
*/ */
send(content, options) { // eslint-disable-line complexity send(content, options) { // eslint-disable-line complexity
if (!options && typeof content === 'object' && !(content instanceof Array)) { if (!options && typeof content === 'object' && !(content instanceof Array)) {

View File

@@ -71,8 +71,8 @@ class TextBasedChannel {
* @example * @example
* // Send a message * // Send a message
* channel.send('hello!') * channel.send('hello!')
* .then(message => console.log(`Sent message: ${message.content}`)) * .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error); * .catch(console.error);
*/ */
send(content, options) { // eslint-disable-line complexity send(content, options) { // eslint-disable-line complexity
if (!options && typeof content === 'object' && !(content instanceof Array)) { if (!options && typeof content === 'object' && !(content instanceof Array)) {
@@ -182,8 +182,8 @@ class TextBasedChannel {
* @example * @example
* // Get messages * // Get messages
* channel.fetchMessages({limit: 10}) * channel.fetchMessages({limit: 10})
* .then(messages => console.log(`Received ${messages.size} messages`)) * .then(messages => console.log(`Received ${messages.size} messages`))
* .catch(console.error); * .catch(console.error);
*/ */
fetchMessages(options = {}) { fetchMessages(options = {}) {
const Message = require('../Message'); const Message = require('../Message');
@@ -308,8 +308,8 @@ class TextBasedChannel {
* @example * @example
* // Create a message collector * // Create a message collector
* const collector = channel.createMessageCollector( * const collector = channel.createMessageCollector(
* m => m.content.includes('discord'), * m => m.content.includes('discord'),
* { time: 15000 } * { time: 15000 }
* ); * );
* collector.on('collect', m => console.log(`Collected ${m.content}`)); * collector.on('collect', m => console.log(`Collected ${m.content}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
@@ -335,8 +335,8 @@ class TextBasedChannel {
* const filter = m => m.content.startsWith('!vote'); * 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'] }) * channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
* .then(collected => console.log(collected.size)) * .then(collected => console.log(collected.size))
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`)); * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
*/ */
awaitMessages(filter, options = {}) { awaitMessages(filter, options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@@ -129,12 +129,12 @@ exports.Endpoints = {
/** /**
* The current status of the client. Here are the available statuses: * The current status of the client. Here are the available statuses:
* - READY * * READY
* - CONNECTING * * CONNECTING
* - RECONNECTING * * RECONNECTING
* - IDLE * * IDLE
* - NEARLY * * NEARLY
* - DISCONNECTED * * DISCONNECTED
* @typedef {number} Status * @typedef {number} Status
*/ */
exports.Status = { exports.Status = {
@@ -148,11 +148,11 @@ exports.Status = {
/** /**
* The current status of a voice connection. Here are the available statuses: * The current status of a voice connection. Here are the available statuses:
* - CONNECTED * * CONNECTED
* - CONNECTING * * CONNECTING
* - AUTHENTICATING * * AUTHENTICATING
* - RECONNECTING * * RECONNECTING
* - DISCONNECTED * * DISCONNECTED
* @typedef {number} VoiceStatus * @typedef {number} VoiceStatus
*/ */
exports.VoiceStatus = { exports.VoiceStatus = {
@@ -243,41 +243,41 @@ exports.Events = {
/** /**
* The type of a websocket message event, e.g. `MESSAGE_CREATE`. Here are the available events: * The type of a websocket message event, e.g. `MESSAGE_CREATE`. Here are the available events:
* - READY * * READY
* - RESUMED * * RESUMED
* - GUILD_SYNC * * GUILD_SYNC
* - GUILD_CREATE * * GUILD_CREATE
* - GUILD_DELETE * * GUILD_DELETE
* - GUILD_UPDATE * * GUILD_UPDATE
* - GUILD_MEMBER_ADD * * GUILD_MEMBER_ADD
* - GUILD_MEMBER_REMOVE * * GUILD_MEMBER_REMOVE
* - GUILD_MEMBER_UPDATE * * GUILD_MEMBER_UPDATE
* - GUILD_MEMBERS_CHUNK * * GUILD_MEMBERS_CHUNK
* - GUILD_ROLE_CREATE * * GUILD_ROLE_CREATE
* - GUILD_ROLE_DELETE * * GUILD_ROLE_DELETE
* - GUILD_ROLE_UPDATE * * GUILD_ROLE_UPDATE
* - GUILD_BAN_ADD * * GUILD_BAN_ADD
* - GUILD_BAN_REMOVE * * GUILD_BAN_REMOVE
* - CHANNEL_CREATE * * CHANNEL_CREATE
* - CHANNEL_DELETE * * CHANNEL_DELETE
* - CHANNEL_UPDATE * * CHANNEL_UPDATE
* - CHANNEL_PINS_UPDATE * * CHANNEL_PINS_UPDATE
* - MESSAGE_CREATE * * MESSAGE_CREATE
* - MESSAGE_DELETE * * MESSAGE_DELETE
* - MESSAGE_UPDATE * * MESSAGE_UPDATE
* - MESSAGE_DELETE_BULK * * MESSAGE_DELETE_BULK
* - MESSAGE_REACTION_ADD * * MESSAGE_REACTION_ADD
* - MESSAGE_REACTION_REMOVE * * MESSAGE_REACTION_REMOVE
* - MESSAGE_REACTION_REMOVE_ALL * * MESSAGE_REACTION_REMOVE_ALL
* - USER_UPDATE * * USER_UPDATE
* - USER_NOTE_UPDATE * * USER_NOTE_UPDATE
* - USER_SETTINGS_UPDATE * * USER_SETTINGS_UPDATE
* - PRESENCE_UPDATE * * PRESENCE_UPDATE
* - VOICE_STATE_UPDATE * * VOICE_STATE_UPDATE
* - TYPING_START * * TYPING_START
* - VOICE_SERVER_UPDATE * * VOICE_SERVER_UPDATE
* - RELATIONSHIP_ADD * * RELATIONSHIP_ADD
* - RELATIONSHIP_REMOVE * * RELATIONSHIP_REMOVE
* @typedef {string} WSEventType * @typedef {string} WSEventType
*/ */
exports.WSEvents = { exports.WSEvents = {
@@ -322,14 +322,14 @@ exports.WSEvents = {
/** /**
* The type of a message, e.g. `DEFAULT`. Here are the available types: * The type of a message, e.g. `DEFAULT`. Here are the available types:
* - DEFAULT * * DEFAULT
* - RECIPIENT_ADD * * RECIPIENT_ADD
* - RECIPIENT_REMOVE * * RECIPIENT_REMOVE
* - CALL * * CALL
* - CHANNEL_NAME_CHANGE * * CHANNEL_NAME_CHANGE
* - CHANNEL_ICON_CHANGE * * CHANNEL_ICON_CHANGE
* - PINS_ADD * * PINS_ADD
* - GUILD_MEMBER_JOIN * * GUILD_MEMBER_JOIN
* @typedef {string} MessageType * @typedef {string} MessageType
*/ */
exports.MessageTypes = [ exports.MessageTypes = [
@@ -345,10 +345,10 @@ exports.MessageTypes = [
/** /**
* The type of a game of a users presence, e.g. `PLAYING`. Here are the available types: * The type of a game of a users presence, e.g. `PLAYING`. Here are the available types:
* - PLAYING * * PLAYING
* - STREAMING * * STREAMING
* - LISTENING * * LISTENING
* - WATCHING * * WATCHING
* @typedef {string} GameType * @typedef {string} GameType
*/ */
exports.GameTypes = [ exports.GameTypes = [
@@ -560,9 +560,9 @@ exports.UserChannelOverrideMap = {
/** /**
* All flags users can have: * All flags users can have:
* - STAFF * * STAFF
* - PARTNER * * PARTNER
* - HYPESQUAD * * HYPESQUAD
* @typedef {string} UserFlags * @typedef {string} UserFlags
*/ */
exports.UserFlags = { exports.UserFlags = {
@@ -606,49 +606,49 @@ exports.Colors = {
/** /**
* An error encountered while performing an API request. Here are the potential errors: * An error encountered while performing an API request. Here are the potential errors:
* - UNKNOWN_ACCOUNT * * UNKNOWN_ACCOUNT
* - UNKNOWN_APPLICATION * * UNKNOWN_APPLICATION
* - UNKNOWN_CHANNEL * * UNKNOWN_CHANNEL
* - UNKNOWN_GUILD * * UNKNOWN_GUILD
* - UNKNOWN_INTEGRATION * * UNKNOWN_INTEGRATION
* - UNKNOWN_INVITE * * UNKNOWN_INVITE
* - UNKNOWN_MEMBER * * UNKNOWN_MEMBER
* - UNKNOWN_MESSAGE * * UNKNOWN_MESSAGE
* - UNKNOWN_OVERWRITE * * UNKNOWN_OVERWRITE
* - UNKNOWN_PROVIDER * * UNKNOWN_PROVIDER
* - UNKNOWN_ROLE * * UNKNOWN_ROLE
* - UNKNOWN_TOKEN * * UNKNOWN_TOKEN
* - UNKNOWN_USER * * UNKNOWN_USER
* - UNKNOWN_EMOJI * * UNKNOWN_EMOJI
* - BOT_PROHIBITED_ENDPOINT * * BOT_PROHIBITED_ENDPOINT
* - BOT_ONLY_ENDPOINT * * BOT_ONLY_ENDPOINT
* - MAXIMUM_GUILDS * * MAXIMUM_GUILDS
* - MAXIMUM_FRIENDS * * MAXIMUM_FRIENDS
* - MAXIMUM_PINS * * MAXIMUM_PINS
* - MAXIMUM_ROLES * * MAXIMUM_ROLES
* - MAXIMUM_REACTIONS * * MAXIMUM_REACTIONS
* - UNAUTHORIZED * * UNAUTHORIZED
* - MISSING_ACCESS * * MISSING_ACCESS
* - INVALID_ACCOUNT_TYPE * * INVALID_ACCOUNT_TYPE
* - CANNOT_EXECUTE_ON_DM * * CANNOT_EXECUTE_ON_DM
* - EMBED_DISABLED * * EMBED_DISABLED
* - CANNOT_EDIT_MESSAGE_BY_OTHER * * CANNOT_EDIT_MESSAGE_BY_OTHER
* - CANNOT_SEND_EMPTY_MESSAGE * * CANNOT_SEND_EMPTY_MESSAGE
* - CANNOT_MESSAGE_USER * * CANNOT_MESSAGE_USER
* - CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL * * CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL
* - CHANNEL_VERIFICATION_LEVEL_TOO_HIGH * * CHANNEL_VERIFICATION_LEVEL_TOO_HIGH
* - OAUTH2_APPLICATION_BOT_ABSENT * * OAUTH2_APPLICATION_BOT_ABSENT
* - MAXIMUM_OAUTH2_APPLICATIONS * * MAXIMUM_OAUTH2_APPLICATIONS
* - INVALID_OAUTH_STATE * * INVALID_OAUTH_STATE
* - MISSING_PERMISSIONS * * MISSING_PERMISSIONS
* - INVALID_AUTHENTICATION_TOKEN * * INVALID_AUTHENTICATION_TOKEN
* - NOTE_TOO_LONG * * NOTE_TOO_LONG
* - INVALID_BULK_DELETE_QUANTITY * * INVALID_BULK_DELETE_QUANTITY
* - CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL * * CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL
* - CANNOT_EXECUTE_ON_SYSTEM_MESSAGE * * CANNOT_EXECUTE_ON_SYSTEM_MESSAGE
* - BULK_DELETE_MESSAGE_TOO_OLD * * BULK_DELETE_MESSAGE_TOO_OLD
* - INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT * * INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT
* - REACTION_BLOCKED * * REACTION_BLOCKED
* @typedef {string} APIError * @typedef {string} APIError
*/ */
exports.APIErrors = { exports.APIErrors = {

View File

@@ -69,7 +69,7 @@ class Permissions {
} }
/** /**
* Gets an object mapping permission name (like `READ_MESSAGES`) to a {@link boolean} indicating whether the * Gets an object mapping permission name (like `VIEW_CHANNEL`) to a {@link boolean} indicating whether the
* permission is available. * permission is available.
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
* @returns {Object} * @returns {Object}
@@ -82,8 +82,8 @@ class Permissions {
/** /**
* Data that can be resolved to give a permission number. This can be: * Data that can be resolved to give a permission number. This can be:
* - A string (see {@link Permissions.FLAGS}) * * A string (see {@link Permissions.FLAGS})
* - A permission number * * A permission number
* @typedef {string|number} PermissionResolvable * @typedef {string|number} PermissionResolvable
*/ */
@@ -102,34 +102,34 @@ class Permissions {
/** /**
* Numeric permission flags. All available properties: * Numeric permission flags. All available properties:
* - `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites) * * `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites)
* - `CREATE_INSTANT_INVITE` (create invitations to the guild) * * `CREATE_INSTANT_INVITE` (create invitations to the guild)
* - `KICK_MEMBERS` * * `KICK_MEMBERS`
* - `BAN_MEMBERS` * * `BAN_MEMBERS`
* - `MANAGE_CHANNELS` (edit and reorder channels) * * `MANAGE_CHANNELS` (edit and reorder channels)
* - `MANAGE_GUILD` (edit the guild information, region, etc.) * * `MANAGE_GUILD` (edit the guild information, region, etc.)
* - `ADD_REACTIONS` (add new reactions to messages) * * `ADD_REACTIONS` (add new reactions to messages)
* - `VIEW_AUDIT_LOG` * * `VIEW_AUDIT_LOG`
* - `VIEW_CHANNELS` * * `VIEW_CHANNEL`
* - `SEND_MESSAGES` * * `SEND_MESSAGES`
* - `SEND_TTS_MESSAGES` * * `SEND_TTS_MESSAGES`
* - `MANAGE_MESSAGES` (delete messages and reactions) * * `MANAGE_MESSAGES` (delete messages and reactions)
* - `EMBED_LINKS` (links posted will have a preview embedded) * * `EMBED_LINKS` (links posted will have a preview embedded)
* - `ATTACH_FILES` * * `ATTACH_FILES`
* - `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord) * * `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord)
* - `MENTION_EVERYONE` * * `MENTION_EVERYONE`
* - `USE_EXTERNAL_EMOJIS` (use emojis from different guilds) * * `USE_EXTERNAL_EMOJIS` (use emojis from different guilds)
* - `CONNECT` (connect to a voice channel) * * `CONNECT` (connect to a voice channel)
* - `SPEAK` (speak in a voice channel) * * `SPEAK` (speak in a voice channel)
* - `MUTE_MEMBERS` (mute members across all voice channels) * * `MUTE_MEMBERS` (mute members across all voice channels)
* - `DEAFEN_MEMBERS` (deafen members across all voice channels) * * `DEAFEN_MEMBERS` (deafen members across all voice channels)
* - `MOVE_MEMBERS` (move members between voice channels) * * `MOVE_MEMBERS` (move members between voice channels)
* - `USE_VAD` (use voice activity detection) * * `USE_VAD` (use voice activity detection)
* - `CHANGE_NICKNAME` * * `CHANGE_NICKNAME`
* - `MANAGE_NICKNAMES` (change other members' nicknames) * * `MANAGE_NICKNAMES` (change other members' nicknames)
* - `MANAGE_ROLES` * * `MANAGE_ROLES`
* - `MANAGE_WEBHOOKS` * * `MANAGE_WEBHOOKS`
* - `MANAGE_EMOJIS` * * `MANAGE_EMOJIS`
* @type {Object} * @type {Object}
* @see {@link https://discordapp.com/developers/docs/topics/permissions} * @see {@link https://discordapp.com/developers/docs/topics/permissions}
*/ */

View File

@@ -70,9 +70,9 @@ class Util {
/** /**
* Parses emoji info out of a string. The string must be one of: * Parses emoji info out of a string. The string must be one of:
* - A UTF-8 emoji (no ID) * * A UTF-8 emoji (no ID)
* - A URL-encoded UTF-8 emoji (no ID) * * A URL-encoded UTF-8 emoji (no ID)
* - A Discord custom emoji (`<:name:id>`) * * A Discord custom emoji (`<:name:id>`)
* @param {string} text Emoji string to parse * @param {string} text Emoji string to parse
* @returns {Object} Object with `name` and `id` properties * @returns {Object} Object with `name` and `id` properties
* @private * @private