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
* @returns {Promise<GuildChannel>}
*/
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);
}
/**