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
This commit is contained in:
Kyra
2018-01-20 19:30:30 +01:00
committed by SpaceEEC
parent b16e6f8262
commit 986e6da196

View File

@@ -445,18 +445,21 @@ class GuildChannel extends Channel {
* @param {string} [options.reason] Reason for cloning this channel * @param {string} [options.reason] Reason for cloning this channel
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
*/ */
clone({ name = this.name, withPermissions = true, withTopic = true, nsfw, parent, bitrate, userLimit, reason } = {}) { clone(options = {}) {
const options = { if (typeof options.withPermissions === 'undefined') options.withPermissions = true;
overwrites: withPermissions ? this.permissionOverwrites : [], Util.mergeDefault({
nsfw: typeof nsfw === 'undefined' ? this.nsfw : nsfw, name: this.name,
parent: parent || this.parent, overwrites: options.withPermissions ? this.permissionOverwrites : [],
bitrate: bitrate || this.bitrate, withTopic: true,
userLimit: userLimit || this.userLimit, nsfw: this.nsfw,
reason, parent: this.parent,
type: this.type, bitrate: this.bitrate,
}; userLimit: this.userLimit,
return this.guild.channels.create(name, options) reason: null,
.then(channel => withTopic ? channel.setTopic(this.topic) : channel); }, options);
options.type = this.type;
return this.guild.channels.create(options.name, options)
.then(channel => options.withTopic ? channel.setTopic(this.topic) : channel);
} }
/** /**