diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 0c86c6db5..5f0e063ab 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -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 ); diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 5521bbcbd..f3616969f 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -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 */ /** diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 59b9879f4..7e3c7c304 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -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} + * @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 }); } /** diff --git a/src/structures/Role.js b/src/structures/Role.js index 122183f46..4790a5c90 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -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 */ /** diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index 2bc565d8b..d190e6a15 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -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} + * @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 }); } /**