mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Docs cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Represents an attachment in a message
|
||||
* Represents an attachment in a message.
|
||||
*/
|
||||
class Attachment {
|
||||
constructor(file, name) {
|
||||
|
||||
@@ -61,8 +61,8 @@ class Channel {
|
||||
* @example
|
||||
* // Delete the channel
|
||||
* channel.delete()
|
||||
* .then() // Success
|
||||
* .catch(console.error); // Log error
|
||||
* .then() // Success
|
||||
* .catch(console.error); // Log error
|
||||
*/
|
||||
delete() {
|
||||
return this.client.api.channels(this.id).delete().then(() => this);
|
||||
|
||||
@@ -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 {string} [options.format='webp'] One of `webp`, `png`, `jpg`
|
||||
* @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 {string} [options.format='webp'] One of `webp`, `png`, `jpg`
|
||||
* @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>}
|
||||
*/
|
||||
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 {Base64Resolvable} data Data of the asset
|
||||
* @param {string} type Type of the asset. `big`, or `small`
|
||||
|
||||
@@ -83,7 +83,7 @@ class ClientUser extends User {
|
||||
/**
|
||||
* All of the user's guild settings
|
||||
* @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();
|
||||
if (data.user_guild_settings) {
|
||||
@@ -119,8 +119,8 @@ class ClientUser extends User {
|
||||
* @example
|
||||
* // Set username
|
||||
* client.user.setUsername('discordjs')
|
||||
* .then(user => console.log(`My new username is ${user.username}`))
|
||||
* .catch(console.error);
|
||||
* .then(user => console.log(`My new username is ${user.username}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setUsername(username, password) {
|
||||
return this.edit({ username }, password);
|
||||
@@ -135,8 +135,8 @@ class ClientUser extends User {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(user => console.log(`My new email is ${user.email}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setEmail(email, password) {
|
||||
return this.edit({ email }, password);
|
||||
@@ -154,8 +154,8 @@ class ClientUser extends User {
|
||||
* @example
|
||||
* // Set password
|
||||
* client.user.setPassword('some new amazing password 456', 'some amazing password 123')
|
||||
* .then(user => console.log('New password set!'))
|
||||
* .catch(console.error);
|
||||
* .then(user => console.log('New password set!'))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPassword(newPassword, options) {
|
||||
return this.edit({ new_password: newPassword }, { password: options.oldPassword, mfaCode: options.mfaCode });
|
||||
@@ -168,8 +168,8 @@ class ClientUser extends User {
|
||||
* @example
|
||||
* // Set avatar
|
||||
* client.user.setAvatar('./avatar.png')
|
||||
* .then(user => console.log(`New avatar set!`))
|
||||
* .catch(console.error);
|
||||
* .then(user => console.log(`New avatar set!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setAvatar(avatar) {
|
||||
if (typeof avatar === 'string' && avatar.startsWith('data:')) {
|
||||
@@ -253,10 +253,10 @@ class ClientUser extends User {
|
||||
|
||||
/**
|
||||
* A user's status. Must be one of:
|
||||
* - `online`
|
||||
* - `idle`
|
||||
* - `invisible`
|
||||
* - `dnd` (do not disturb)
|
||||
* * `online`
|
||||
* * `idle`
|
||||
* * `invisible`
|
||||
* * `dnd` (do not disturb)
|
||||
* @typedef {string} PresenceStatus
|
||||
*/
|
||||
|
||||
|
||||
@@ -115,10 +115,10 @@ class Emoji {
|
||||
* @param {string} [reason] Reason for editing this emoji
|
||||
* @returns {Promise<Emoji>}
|
||||
* @example
|
||||
* // Edit a emoji
|
||||
* // Edit an emoji
|
||||
* emoji.edit({name: 'newemoji'})
|
||||
* .then(e => console.log(`Edited emoji ${e}`))
|
||||
* .catch(console.error);
|
||||
* .then(e => console.log(`Edited emoji ${e}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(data, reason) {
|
||||
return this.client.api.guilds(this.guild.id).emojis(this.id)
|
||||
|
||||
@@ -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 {string} [options.format='webp'] One of `webp`, `png`, `jpg`
|
||||
* @param {number} [options.size=128] One of `128`, '256', `512`, `1024`, `2048`
|
||||
|
||||
@@ -220,7 +220,8 @@ class Guild {
|
||||
|
||||
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>}
|
||||
*/
|
||||
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 {string} [options.format='webp'] One of `webp`, `png`, `jpg`
|
||||
* @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}
|
||||
* @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 {string} [options.format='webp'] One of `webp`, `png`, `jpg`
|
||||
* @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>>}
|
||||
*/
|
||||
fetchInvites() {
|
||||
@@ -566,7 +568,7 @@ class Guild {
|
||||
fetchMembers({ query = '', limit = 0 } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.memberCount === this.members.size) {
|
||||
resolve((query || limit) ? new Collection() : this.members);
|
||||
resolve(query || limit ? new Collection() : this.members);
|
||||
return;
|
||||
}
|
||||
this.client.ws.send({
|
||||
@@ -585,7 +587,7 @@ class Guild {
|
||||
}
|
||||
if (this.memberCount === this.members.size || ((query || limit) && members.size < 1000)) {
|
||||
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);
|
||||
@@ -636,11 +638,11 @@ class Guild {
|
||||
* @example
|
||||
* // Set the guild name and region
|
||||
* guild.edit({
|
||||
* name: 'Discord Guild',
|
||||
* region: 'london',
|
||||
* name: 'Discord Guild',
|
||||
* region: 'london',
|
||||
* })
|
||||
* .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`))
|
||||
* .catch(console.error);
|
||||
* .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(data, reason) {
|
||||
const _data = {};
|
||||
@@ -841,8 +843,8 @@ class Guild {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
ban(user, options = { days: 0 }) {
|
||||
if (options.days) options['delete-message-days'] = options.days;
|
||||
@@ -868,8 +870,8 @@ class Guild {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
unban(user, reason) {
|
||||
const id = this.client.resolver.resolveUserID(user);
|
||||
@@ -929,8 +931,8 @@ class Guild {
|
||||
* @example
|
||||
* // Create a new text channel
|
||||
* guild.createChannel('new-general', 'text')
|
||||
* .then(channel => console.log(`Created new channel ${channel}`))
|
||||
* .catch(console.error);
|
||||
* .then(channel => console.log(`Created new channel ${channel}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
createChannel(name, type, { overwrites, reason } = {}) {
|
||||
if (overwrites instanceof Collection || overwrites instanceof Array) {
|
||||
@@ -981,8 +983,8 @@ class Guild {
|
||||
* @returns {Promise<Guild>}
|
||||
* @example
|
||||
* guild.updateChannels([{ channel: channelID, position: newChannelIndex }])
|
||||
* .then(guild => console.log(`Updated channel positions for ${guild.id}`))
|
||||
* .catch(console.error);
|
||||
* .then(guild => console.log(`Updated channel positions for ${guild.id}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setChannelPositions(channelPositions) {
|
||||
const data = new Array(channelPositions.length);
|
||||
@@ -1013,8 +1015,8 @@ class Guild {
|
||||
* @example
|
||||
* // Create a new role
|
||||
* guild.createRole()
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.error);
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.error);
|
||||
* @example
|
||||
* // Create a new role with data and a reason
|
||||
* guild.createRole({
|
||||
@@ -1024,8 +1026,8 @@ class Guild {
|
||||
* },
|
||||
* reason: 'we needed a role for Super Cool People',
|
||||
* })
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.error)
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.error)
|
||||
*/
|
||||
createRole({ data = {}, reason } = {}) {
|
||||
if (data.color) data.color = Util.resolveColor(data.color);
|
||||
@@ -1050,13 +1052,13 @@ class Guild {
|
||||
* @example
|
||||
* // 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);
|
||||
* .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
|
||||
* guild.createEmoji('./memes/banana.png', 'banana')
|
||||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
|
||||
* .catch(console.error);
|
||||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
createEmoji(attachment, name, { roles, reason } = {}) {
|
||||
if (typeof attachment === 'string' && attachment.startsWith('data:')) {
|
||||
@@ -1102,8 +1104,8 @@ class Guild {
|
||||
* @example
|
||||
* // Leave a guild
|
||||
* guild.leave()
|
||||
* .then(g => console.log(`Left the guild ${g}`))
|
||||
* .catch(console.error);
|
||||
* .then(g => console.log(`Left the guild ${g}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
leave() {
|
||||
if (this.ownerID === this.client.user.id) return Promise.reject(new Error('GUILD_OWNED'));
|
||||
@@ -1117,8 +1119,8 @@ class Guild {
|
||||
* @example
|
||||
* // Delete a guild
|
||||
* guild.delete()
|
||||
* .then(g => console.log(`Deleted the guild ${g}`))
|
||||
* .catch(console.error);
|
||||
* .then(g => console.log(`Deleted the guild ${g}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
delete() {
|
||||
return this.client.api.guilds(this.id).delete()
|
||||
|
||||
@@ -184,7 +184,7 @@ class GuildAuditLogsEntry {
|
||||
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
|
||||
* @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
|
||||
|
||||
@@ -146,10 +146,10 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // Overwrite permissions for a message author
|
||||
* message.channel.overwritePermissions(message.author, {
|
||||
* SEND_MESSAGES: false
|
||||
* SEND_MESSAGES: false
|
||||
* })
|
||||
* .then(() => console.log('Done!'))
|
||||
* .catch(console.error);
|
||||
* .then(() => console.log('Done!'))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
overwritePermissions(userOrRole, options, reason) {
|
||||
const payload = {
|
||||
@@ -228,8 +228,8 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // Edit a channel
|
||||
* channel.edit({name: 'new-channel'})
|
||||
* .then(c => console.log(`Edited channel ${c}`))
|
||||
* .catch(console.error);
|
||||
* .then(c => console.log(`Edited channel ${c}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(data, reason) {
|
||||
return this.client.api.channels(this.id).patch({
|
||||
@@ -252,8 +252,8 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // Set a new channel name
|
||||
* channel.setName('not_general')
|
||||
* .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
|
||||
* .catch(console.error);
|
||||
* .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setName(name, reason) {
|
||||
return this.edit({ name }, reason);
|
||||
@@ -267,8 +267,8 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // Set a new channel position
|
||||
* channel.setPosition(2)
|
||||
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
|
||||
* .catch(console.error);
|
||||
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPosition(position, relative) {
|
||||
return this.guild.setChannelPosition(this, position, relative).then(() => this);
|
||||
@@ -282,8 +282,8 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setTopic(topic, reason) {
|
||||
return this.edit({ topic }, reason);
|
||||
@@ -366,8 +366,8 @@ class GuildChannel extends Channel {
|
||||
* @example
|
||||
* // Delete the channel
|
||||
* channel.delete('making room for new channels')
|
||||
* .then() // Success
|
||||
* .catch(console.error); // Log error
|
||||
* .then() // Success
|
||||
* .catch(console.error); // Log error
|
||||
*/
|
||||
delete(reason) {
|
||||
return this.client.api.channels(this.id).delete({ reason }).then(() => this);
|
||||
|
||||
@@ -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
|
||||
* string, the ban reason. Supplying an object allows you to do both.
|
||||
* @param {number} [options.days=0] Number of days of messages to delete
|
||||
|
||||
@@ -59,8 +59,8 @@ class Message {
|
||||
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
|
||||
* where the author is still a member.
|
||||
* Represents the author of the message as a guild member
|
||||
* Only available if the message comes from a guild where the author is still a member
|
||||
* @type {?GuildMember}
|
||||
*/
|
||||
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 relevant mention in the message content will not be converted
|
||||
* 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.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
@@ -271,8 +271,8 @@ class Message {
|
||||
* @example
|
||||
* // Create a reaction collector
|
||||
* const collector = message.createReactionCollector(
|
||||
* (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someID',
|
||||
* { time: 15000 }
|
||||
* (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someID',
|
||||
* { time: 15000 }
|
||||
* );
|
||||
* collector.on('collect', r => console.log(`Collected ${r.emoji.name}`));
|
||||
* 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
|
||||
* filter.
|
||||
* Similar to createCollector but in promise form.
|
||||
* Resolves with a collection of reactions that pass the specified filter.
|
||||
* @param {CollectorFilter} filter The filter function to use
|
||||
* @param {AwaitReactionsOptions} [options={}] Optional options to pass to the internal collector
|
||||
* @returns {Promise<Collection<string, MessageReaction>>}
|
||||
@@ -362,8 +362,8 @@ class Message {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(msg => console.log(`Updated the content of a message from ${msg.author}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(content, options) {
|
||||
if (!options && typeof content === 'object' && !(content instanceof Array)) {
|
||||
@@ -448,8 +448,8 @@ class Message {
|
||||
* @example
|
||||
* // Delete a message
|
||||
* message.delete()
|
||||
* .then(msg => console.log(`Deleted message from ${msg.author}`))
|
||||
* .catch(console.error);
|
||||
* .then(msg => console.log(`Deleted message from ${msg.author}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
delete({ timeout = 0, reason } = {}) {
|
||||
if (timeout <= 0) {
|
||||
@@ -477,8 +477,8 @@ class Message {
|
||||
* @example
|
||||
* // Reply to a message
|
||||
* message.reply('Hey, I\'m a reply!')
|
||||
* .then(msg => console.log(`Sent a reply to ${msg.author}`))
|
||||
* .catch(console.error);
|
||||
* .then(msg => console.log(`Sent a reply to ${msg.author}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
reply(content, options) {
|
||||
if (!options && typeof content === 'object' && !(content instanceof Array)) {
|
||||
|
||||
@@ -21,7 +21,8 @@ class MessageCollector extends Collector {
|
||||
super(channel.client, filter, options);
|
||||
|
||||
/**
|
||||
* @type {TextBasedChannel} channel The channel
|
||||
* The channel
|
||||
* @type {TextBasedChannel}
|
||||
*/
|
||||
this.channel = channel;
|
||||
|
||||
@@ -49,7 +50,7 @@ class MessageCollector extends Collector {
|
||||
/**
|
||||
* Handle a message for possible collection.
|
||||
* @param {Message} message The message that could be collected
|
||||
* @returns {?{key: Snowflake, value: Message}} Message data to collect
|
||||
* @returns {?{key: Snowflake, value: Message}}
|
||||
* @private
|
||||
*/
|
||||
collect(message) {
|
||||
@@ -64,7 +65,7 @@ class MessageCollector extends Collector {
|
||||
/**
|
||||
* Handle a message for possible disposal.
|
||||
* @param {Message} message The message that could be disposed
|
||||
* @returns {?string} The message ID.
|
||||
* @returns {?string}
|
||||
*/
|
||||
dispose(message) {
|
||||
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.
|
||||
* @returns {?string} Reason to end the collector, if any
|
||||
* @returns {?string}
|
||||
* @private
|
||||
*/
|
||||
endReason() {
|
||||
|
||||
@@ -57,7 +57,7 @@ class MessageEmbed {
|
||||
this.fields = data.fields || [];
|
||||
|
||||
/**
|
||||
* The thumbnail of this embed, if there is one
|
||||
* The thumbnail of this embed (if there is one)
|
||||
* @type {?Object}
|
||||
* @property {string} url URL for this thumbnail
|
||||
* @property {string} proxyURL ProxyURL for this thumbnail
|
||||
@@ -87,7 +87,7 @@ class MessageEmbed {
|
||||
} : null;
|
||||
|
||||
/**
|
||||
* The video of this embed, if there is one
|
||||
* The video of this embed (if there is one)
|
||||
* @type {?Object}
|
||||
* @property {string} url URL of this video
|
||||
* @property {number} height Height of this video
|
||||
@@ -96,7 +96,7 @@ class MessageEmbed {
|
||||
this.video = data.video;
|
||||
|
||||
/**
|
||||
* The author of this embed, if there is one
|
||||
* The author of this embed (if there is one)
|
||||
* @type {?Object}
|
||||
* @property {string} name The name of this author
|
||||
* @property {string} url URL of this author
|
||||
@@ -111,7 +111,7 @@ class MessageEmbed {
|
||||
} : null;
|
||||
|
||||
/**
|
||||
* The provider of this embed, if there is one
|
||||
* The provider of this embed (if there is one)
|
||||
* @type {?Object}
|
||||
* @property {string} name The name of this provider
|
||||
* @property {string} url URL of this provider
|
||||
@@ -132,14 +132,12 @@ class MessageEmbed {
|
||||
} : null;
|
||||
|
||||
/**
|
||||
* The files of this embed
|
||||
* @type {?Object}
|
||||
* @property {Array<FileOptions|string|Attachment>} files Files to attach
|
||||
*/
|
||||
* The files of this embed
|
||||
* @type {?Object}
|
||||
* @property {Array<FileOptions|string|Attachment>} files Files to attach
|
||||
*/
|
||||
if (data.files) {
|
||||
for (let file of data.files) {
|
||||
if (file instanceof Attachment) file = file.file;
|
||||
}
|
||||
for (let file of data.files) if (file instanceof Attachment) file = file.file;
|
||||
} else { data.files = null; }
|
||||
}
|
||||
|
||||
@@ -166,7 +164,7 @@ class MessageEmbed {
|
||||
* @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
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
addField(name, value, inline = false) {
|
||||
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)`.
|
||||
* @param {boolean} [inline=false] Set the field to display inline
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
addBlankField(inline = false) {
|
||||
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
|
||||
* setting an embed image or author/footer icons. Only one file may be attached.
|
||||
* @param {Array<FileOptions|string|Attachment>} files Files to attach
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
attachFiles(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 {string} [iconURL] The icon URL of the author
|
||||
* @param {string} [url] The URL of the author
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setAuthor(name, iconURL, url) {
|
||||
this.author = { name: Util.resolveString(name), iconURL, url };
|
||||
@@ -217,7 +215,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Sets the color of this embed.
|
||||
* @param {ColorResolvable} color The color of the embed
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setColor(color) {
|
||||
this.color = Util.resolveColor(color);
|
||||
@@ -227,7 +225,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Sets the description of this embed.
|
||||
* @param {StringResolvable} description The description
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setDescription(description) {
|
||||
description = Util.resolveString(description);
|
||||
@@ -240,7 +238,7 @@ class MessageEmbed {
|
||||
* Sets the footer of this embed.
|
||||
* @param {StringResolvable} text The text of the footer
|
||||
* @param {string} [iconURL] The icon URL of the footer
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setFooter(text, iconURL) {
|
||||
text = Util.resolveString(text);
|
||||
@@ -252,7 +250,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Set the image of this embed.
|
||||
* @param {string} url The URL of the image
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setImage(url) {
|
||||
this.image = { url };
|
||||
@@ -262,7 +260,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Set the thumbnail of this embed.
|
||||
* @param {string} url The URL of the thumbnail
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setThumbnail(url) {
|
||||
this.thumbnail = { url };
|
||||
@@ -272,7 +270,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Sets the timestamp of this embed.
|
||||
* @param {Date} [timestamp=current date] The timestamp
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setTimestamp(timestamp = new Date()) {
|
||||
this.timestamp = timestamp.getTime();
|
||||
@@ -282,7 +280,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Sets the title of this embed.
|
||||
* @param {StringResolvable} title The title
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setTitle(title) {
|
||||
title = Util.resolveString(title);
|
||||
@@ -294,7 +292,7 @@ class MessageEmbed {
|
||||
/**
|
||||
* Sets the URL of this embed.
|
||||
* @param {string} url The URL
|
||||
* @returns {MessageEmbed} This embed
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
setURL(url) {
|
||||
this.url = url;
|
||||
|
||||
@@ -118,8 +118,8 @@ class MessageMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is mentioned. Takes into account user mentions, role
|
||||
* mentions, and @everyone/@here mentions.
|
||||
* Check if a user is mentioned.
|
||||
* Takes into account user mentions, role mentions, and @everyone/@here mentions.
|
||||
* @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
|
||||
* @returns {boolean}
|
||||
|
||||
@@ -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
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
||||
@@ -65,7 +65,7 @@ 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
|
||||
* @returns {?{key: Snowflake, value: MessageReaction}}
|
||||
* @private
|
||||
*/
|
||||
collect(reaction) {
|
||||
@@ -79,7 +79,7 @@ class ReactionCollector extends Collector {
|
||||
/**
|
||||
* Handle a reaction deletion for possible disposal.
|
||||
* @param {MessageReaction} reaction The reaction to possibly dispose
|
||||
* @returns {?Snowflake|string} The reaction key
|
||||
* @returns {?Snowflake|string}
|
||||
*/
|
||||
dispose(reaction) {
|
||||
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.
|
||||
* @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) {
|
||||
return reaction.emoji.id || reaction.emoji.name;
|
||||
|
||||
@@ -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>}
|
||||
* @example
|
||||
* // Print the serialized role permissions
|
||||
@@ -198,8 +198,8 @@ class Role {
|
||||
* @example
|
||||
* // Edit a role
|
||||
* role.edit({name: 'new role'})
|
||||
* .then(r => console.log(`Edited role ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Edited role ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(data, reason) {
|
||||
if (data.permissions) data.permissions = Permissions.resolve(data.permissions);
|
||||
@@ -226,8 +226,8 @@ class Role {
|
||||
* @example
|
||||
* // Set the name of the role
|
||||
* role.setName('new role')
|
||||
* .then(r => console.log(`Edited name of role ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Edited name of role ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setName(name, reason) {
|
||||
return this.edit({ name }, reason);
|
||||
@@ -241,8 +241,8 @@ class Role {
|
||||
* @example
|
||||
* // Set the color of a role
|
||||
* role.setColor('#FF0000')
|
||||
* .then(r => console.log(`Set color of role ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Set color of role ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setColor(color, reason) {
|
||||
return this.edit({ color }, reason);
|
||||
@@ -256,8 +256,8 @@ class Role {
|
||||
* @example
|
||||
* // Set the hoist of the role
|
||||
* role.setHoist(true)
|
||||
* .then(r => console.log(`Role hoisted: ${r.hoist}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Role hoisted: ${r.hoist}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setHoist(hoist, reason) {
|
||||
return this.edit({ hoist }, reason);
|
||||
@@ -271,8 +271,8 @@ class Role {
|
||||
* @example
|
||||
* // Set the position of the role
|
||||
* role.setPosition(1)
|
||||
* .then(r => console.log(`Role position: ${r.position}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Role position: ${r.position}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPosition(position, relative) {
|
||||
return this.guild.setRolePosition(this, position, relative).then(() => this);
|
||||
@@ -286,8 +286,8 @@ class Role {
|
||||
* @example
|
||||
* // Set the permissions of the role
|
||||
* role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS'])
|
||||
* .then(r => console.log(`Role updated ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Role updated ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPermissions(permissions, reason) {
|
||||
return this.edit({ permissions }, reason);
|
||||
@@ -301,8 +301,8 @@ class Role {
|
||||
* @example
|
||||
* // Make the role mentionable
|
||||
* role.setMentionable(true)
|
||||
* .then(r => console.log(`Role updated ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Role updated ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setMentionable(mentionable, reason) {
|
||||
return this.edit({ mentionable }, reason);
|
||||
@@ -315,8 +315,8 @@ class Role {
|
||||
* @example
|
||||
* // Delete a role
|
||||
* role.delete()
|
||||
* .then(r => console.log(`Deleted role ${r}`))
|
||||
* .catch(console.error);
|
||||
* .then(r => console.log(`Deleted role ${r}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
delete(reason) {
|
||||
return this.client.api.guilds[this.guild.id].roles[this.id].delete({ reason })
|
||||
|
||||
@@ -54,9 +54,9 @@ class TextChannel extends GuildChannel {
|
||||
* @param {string} [reason] Reason for creating this 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}`))
|
||||
* .catch(console.error)
|
||||
* channel.createWebhook('Snek', 'https://i.imgur.com/mI8XcpG.jpg')
|
||||
* .then(webhook => console.log(`Created webhook ${webhook}`))
|
||||
* .catch(console.error)
|
||||
*/
|
||||
createWebhook(name, avatar, reason) {
|
||||
if (typeof avatar === 'string' && avatar.startsWith('data:')) {
|
||||
|
||||
@@ -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 {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`
|
||||
@@ -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 {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`
|
||||
|
||||
@@ -14,7 +14,7 @@ class UserProfile {
|
||||
this.user = user;
|
||||
|
||||
/**
|
||||
* The client that created the instance of the UserProfile.
|
||||
* The client that created the instance of the UserProfile
|
||||
* @name UserProfile#client
|
||||
* @type {Client}
|
||||
* @readonly
|
||||
|
||||
@@ -82,8 +82,8 @@ class VoiceChannel extends GuildChannel {
|
||||
* @example
|
||||
* // Set the bitrate of a voice channel
|
||||
* voiceChannel.setBitrate(48)
|
||||
* .then(vc => console.log(`Set bitrate to ${vc.bitrate}kbps for ${vc.name}`))
|
||||
* .catch(console.error);
|
||||
* .then(vc => console.log(`Set bitrate to ${vc.bitrate}kbps for ${vc.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setBitrate(bitrate, reason) {
|
||||
bitrate *= 1000;
|
||||
@@ -98,8 +98,8 @@ class VoiceChannel extends GuildChannel {
|
||||
* @example
|
||||
* // 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);
|
||||
* .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setUserLimit(userLimit, reason) {
|
||||
return this.edit({ userLimit }, reason);
|
||||
@@ -111,8 +111,8 @@ class VoiceChannel extends GuildChannel {
|
||||
* @example
|
||||
* // Join a voice channel
|
||||
* voiceChannel.join()
|
||||
* .then(connection => console.log('Connected!'))
|
||||
* .catch(console.error);
|
||||
* .then(connection => console.log('Connected!'))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
join() {
|
||||
if (this.client.browser) return Promise.reject(new Error('VOICE_NO_BROWSER'));
|
||||
|
||||
@@ -99,8 +99,8 @@ class Webhook {
|
||||
* @example
|
||||
* // Send a message
|
||||
* webhook.send('hello!')
|
||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||
* .catch(console.error);
|
||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
send(content, options) { // eslint-disable-line complexity
|
||||
if (!options && typeof content === 'object' && !(content instanceof Array)) {
|
||||
|
||||
@@ -71,8 +71,8 @@ class TextBasedChannel {
|
||||
* @example
|
||||
* // Send a message
|
||||
* channel.send('hello!')
|
||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||
* .catch(console.error);
|
||||
* .then(message => console.log(`Sent message: ${message.content}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
send(content, options) { // eslint-disable-line complexity
|
||||
if (!options && typeof content === 'object' && !(content instanceof Array)) {
|
||||
@@ -182,8 +182,8 @@ class TextBasedChannel {
|
||||
* @example
|
||||
* // Get messages
|
||||
* channel.fetchMessages({limit: 10})
|
||||
* .then(messages => console.log(`Received ${messages.size} messages`))
|
||||
* .catch(console.error);
|
||||
* .then(messages => console.log(`Received ${messages.size} messages`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchMessages(options = {}) {
|
||||
const Message = require('../Message');
|
||||
@@ -308,8 +308,8 @@ class TextBasedChannel {
|
||||
* @example
|
||||
* // Create a message collector
|
||||
* const collector = channel.createMessageCollector(
|
||||
* m => m.content.includes('discord'),
|
||||
* { time: 15000 }
|
||||
* m => m.content.includes('discord'),
|
||||
* { time: 15000 }
|
||||
* );
|
||||
* collector.on('collect', m => console.log(`Collected ${m.content}`));
|
||||
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
||||
@@ -335,8 +335,8 @@ class TextBasedChannel {
|
||||
* const filter = m => m.content.startsWith('!vote');
|
||||
* // 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.`));
|
||||
* .then(collected => console.log(collected.size))
|
||||
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
|
||||
*/
|
||||
awaitMessages(filter, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user