Document GuildChannel.edit, add VoiceChannel.setUserLimit, fix typo (#866)

This commit is contained in:
Programmix
2016-10-31 22:42:05 -07:00
committed by Schuyler Cebulskie
parent 2a50dad852
commit 9a61de1493
5 changed files with 57 additions and 21 deletions

View File

@@ -159,11 +159,13 @@ class RESTMethods {
});
}
updateChannel(channel, data) {
data.name = (data.name || channel.name).trim();
data.topic = data.topic || channel.topic;
data.position = data.position || channel.position;
data.bitrate = data.bitrate || channel.bitrate;
updateChannel(channel, _data) {
const data = {};
data.name = (_data.name || channel.name).trim();
data.topic = _data.topic || channel.topic;
data.position = _data.position || channel.position;
data.bitrate = _data.bitrate || channel.bitrate;
data.user_limit = _data.userLimit || channel.userLimit;
return this.rest.makeRequest('patch', Constants.Endpoints.channel(channel.id), true, data).then(newData =>
this.rest.client.actions.ChannelUpdate.handle(newData).updated
);

View File

@@ -347,14 +347,14 @@ class Guild {
/**
* The data for editing a guild
* @typedef {Object} GuildEditData
* @property {string} name The name of the guild
* @property {string} region The region of the guild
* @property {number} verificationLevel The verification level of the guild
* @property {GuildChannelResolvable} afkChannel The AFK channel of the guild
* @property {number} afkTimeout The AFK timeout of the guild
* @property {Base64Resolvable} icon The icon of the guild
* @property {GuildMemberResolvable} owner The owner of the guild
* @property {Base64Resolvable} splash The splash screen of the guild
* @property {string} [name] The name of the guild
* @property {string} [region] The region of the guild
* @property {number} [verificationLevel] The verification level of the guild
* @property {GuildChannelResolvable} [afkChannel] The AFK channel of the guild
* @property {number} [afkTimeout] The AFK timeout of the guild
* @property {Base64Resolvable} [icon] The icon of the guild
* @property {GuildMemberResolvable} [owner] The owner of the guild
* @property {Base64Resolvable} [splash] The splash screen of the guild
*/
/**

View File

@@ -161,6 +161,26 @@ class GuildChannel extends Channel {
return this.client.rest.methods.setChannelOverwrite(this, payload);
}
/**
* The data for a guild channel
* @typedef {Object} ChannelData
* @property {string} [name] The name of the channel
* @property {number} [position] The position of the channel
* @property {string} [topic] The topic of the text channel
* @property {number} [bitrate] The bitrate of the voice channel
* @property {number} [userLimit] The user limit of the channel
*/
/**
* Edits the channel
* @param {ChannelData} data The new data for the channel
* @returns {Promise<GuildChannel>}
* @example
* // edit a channel
* channel.edit({name: 'new-channel'})
* .then(c => console.log(`Edited channel ${c}`))
* .catch(console.error);
*/
edit(data) {
return this.client.rest.methods.updateChannel(this, data);
}
@@ -176,7 +196,7 @@ class GuildChannel extends Channel {
* .catch(console.error);
*/
setName(name) {
return this.client.rest.methods.updateChannel(this, { name });
return this.edit({ name });
}
/**

View File

@@ -166,12 +166,12 @@ class Role {
/**
* The data for a role
* @typedef {Object} RoleData
* @property {string} name The name of the role
* @property {number|string} color The color of the role, either a hex string or a base 10 number
* @property {boolean} hoist Whether or not the role should be hoisted
* @property {number} position The position of the role
* @property {string[]} permissions The permissions of the role
* @property {boolean} mentionable Whether or not the role should be mentionable
* @property {string} [name] The name of the role
* @property {number|string} [color] The color of the role, either a hex string or a base 10 number
* @property {boolean} [hoist] Whether or not the role should be hoisted
* @property {number} [position] The position of the role
* @property {string[]} [permissions] The permissions of the role
* @property {boolean} [mentionable] Whether or not the role should be mentionable
*/
/**

View File

@@ -72,7 +72,21 @@ class VoiceChannel extends GuildChannel {
* .catch(console.error);
*/
setBitrate(bitrate) {
return this.rest.client.rest.methods.updateChannel(this, { bitrate });
return this.edit({ bitrate });
}
/**
* Sets the user limit of the channel
* @param {number} userLimit The new user limit
* @returns {Promise<VoiceChannel>}
* @example
* // set the user limit of a voice channel
* voiceChannel.setUserLimit(42)
* .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
* .catch(console.error);
*/
setUserLimit(userLimit) {
return this.edit({ userLimit });
}
/**