mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user