From 986e6da196525ddf64d666a71c5dc70a450e6cd1 Mon Sep 17 00:00:00 2001 From: Kyra Date: Sat, 20 Jan 2018 19:30:30 +0100 Subject: [PATCH] Fix(GuildChannel#clone) options.parent not accepting (falsy) null. (#2262) * Fixed (falsy) options not being set correctly * Requested changes. As a side note, I also default `options.withPermissions` for simplicity, and because it gets ignored in [`GuildChannelStore#create()`](https://discord.js.org/#/docs/main/master/class/GuildChannelStore?scrollTo=create). * Fixed the overwrites option --- src/structures/GuildChannel.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index c4d4c7bbf..a79f11bae 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -445,18 +445,21 @@ class GuildChannel extends Channel { * @param {string} [options.reason] Reason for cloning this channel * @returns {Promise} */ - clone({ name = this.name, withPermissions = true, withTopic = true, nsfw, parent, bitrate, userLimit, reason } = {}) { - const options = { - overwrites: withPermissions ? this.permissionOverwrites : [], - nsfw: typeof nsfw === 'undefined' ? this.nsfw : nsfw, - parent: parent || this.parent, - bitrate: bitrate || this.bitrate, - userLimit: userLimit || this.userLimit, - reason, - type: this.type, - }; - return this.guild.channels.create(name, options) - .then(channel => withTopic ? channel.setTopic(this.topic) : channel); + clone(options = {}) { + if (typeof options.withPermissions === 'undefined') options.withPermissions = true; + Util.mergeDefault({ + name: this.name, + overwrites: options.withPermissions ? this.permissionOverwrites : [], + withTopic: true, + nsfw: this.nsfw, + parent: this.parent, + bitrate: this.bitrate, + userLimit: this.userLimit, + reason: null, + }, options); + options.type = this.type; + return this.guild.channels.create(options.name, options) + .then(channel => options.withTopic ? channel.setTopic(this.topic) : channel); } /**