Skip to content

Commit

Permalink
Fold reason into createChannel() options
Browse files Browse the repository at this point in the history
  • Loading branch information
abalabahaha committed Nov 17, 2019
1 parent 477d952 commit 0aa4f17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ class Client extends EventEmitter {
* @arg {String} guildID The ID of the guild to create the channel in
* @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 {Object | String} [options] The properties the channel should have. If `options` is a string, it will be treated as `options.parentID` (see below). Passing a string is deprecated and will not be supported in future versions.
* @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 category channel for this channel
* @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects
* @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.reason] The reason to be displayed in audit logs
* @arg {Number} [options.userLimit] The channel user limit (voice channels only)
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>}
*/
createChannel(guildID, name, type, reason, options = {}) {
Expand All @@ -398,10 +398,18 @@ class Client extends EventEmitter {
parentID: options
};
}
if(typeof reason === "string") { // Reason is deprecated, will be folded into options
this.emit("warn", "[DEPRECATED] createChannel() was called with a string `reason` argument");
options.reason = reason;
reason = undefined;
} else if(typeof reason === "object" && reason !== null) {
options = reason;
reason = undefined;
}
return this.requestHandler.request("POST", Endpoints.GUILD_CHANNELS(guildID), true, {
name: name,
type: type,
reason: reason,
reason: options.reason,
topic: options.topic,
nsfw: options.nsfw,
bitrate: options.bitrate,
Expand Down
6 changes: 3 additions & 3 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ class Guild extends Base {
* Create a channel in the guild
* @arg {String} name The name of the channel
* @arg {Number} [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 {Object | String} [options] The properties the channel should have. If `options` is a string, it will be treated as `options.parentID` (see below). Passing a string is deprecated and will not be supported in future versions.
* @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 category channel for this channel
* @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects
* @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.reason] The reason to be displayed in audit logs
* @arg {Number} [options.userLimit] The channel user limit (voice channels only)
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>}
*/
createChannel(name, type, reason, options) {
Expand Down

0 comments on commit 0aa4f17

Please sign in to comment.