Skip to content

Commit

Permalink
Add extra createChannel options
Browse files Browse the repository at this point in the history
Fixes #457. You know, some of these were introduced years ago, but this function has barely changed.
  • Loading branch information
abalabahaha committed Feb 3, 2019
1 parent 86ee584 commit 97bd436
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/Client.js
Expand Up @@ -357,16 +357,32 @@ class Client extends EventEmitter {
* @arg {String} name The name of the channel
* @arg {String} [type=0] The type of the channel, either 0 (text), 2 (voice), or 4 (category)
* @arg {String} [reason] The reason to be displayed in audit logs
* @arg {String} [parentID] ID of the parent category for a channel
* @arg {Object} [options] The properties the channel should have
* @arg {String} [options.topic] The topic of the channel (text channels only)
* @arg {Boolean} [options.nsfw] The nsfw status of the channel
* @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only)
* @arg {Number} [options.userLimit] The channel user limit (voice channels only)
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only)
* @arg {String?} [options.parentID] The ID of the parent channel category for this channel
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>}
*/
createChannel(guildID, name, type, reason, parentID) {
createChannel(guildID, name, type, reason, options = {}) {
const guild = this.guilds.get(guildID);
if(typeof options === "string") { // This used to be parentID, back-compat

This comment has been minimized.

Copy link
@Brayzure

Brayzure Feb 3, 2019

Contributor

Do we really want to have this? Can always bump major, since without it it's breaking, and we've got a quite a few things in the dev branch anyway.

This comment has been minimized.

Copy link
@LJNeon

LJNeon Feb 3, 2019

Contributor

Also wouldn't createChannel(guildID, options = {}, reason) be better if we are going to make breaking changes? Both name and type are part of the option object.

This comment has been minimized.

Copy link
@Brayzure

Brayzure Feb 3, 2019

Contributor

I think name and type should be their own arguments, seeing as they are not optional.

options = {
parentID: options
};
}
return this.requestHandler.request("POST", Endpoints.GUILD_CHANNELS(guildID), true, {
name,
type,
reason,
parent_id: parentID
name: name,
type: type,
reason: reason,
topic: options.topic,
nsfw: options.nsfw,
bitrate: options.bitrate,
user_limit: options.userLimit,
rate_limit_per_user: options.rateLimitPerUser,
parent_id: options.parentID
}).then((channel) => {
if(channel.type === 0) {
return new TextChannel(channel, guild);
Expand Down

0 comments on commit 97bd436

Please sign in to comment.