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

@@ -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()