From 1b7447304f959c90b7cea0c2529421f444f7359a Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Thu, 10 Jun 2021 17:14:30 +0200 Subject: [PATCH 1/2] fix(GuildChannel): spread clone options to avoid infinite recursion --- src/structures/GuildChannel.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index db71485bb5ea..b8e12341c354 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -573,22 +573,20 @@ class GuildChannel extends Channel { * @returns {Promise} */ clone(options = {}) { - Util.mergeDefault( - { - name: this.name, - permissionOverwrites: this.permissionOverwrites, - topic: this.topic, - type: this.type, - nsfw: this.nsfw, - parent: this.parent, - bitrate: this.bitrate, - userLimit: this.userLimit, - rateLimitPerUser: this.rateLimitPerUser, - position: this.position, - reason: null, - }, - options, - ); + options = { + name: this.name, + permissionOverwrites: this.permissionOverwrites, + topic: this.topic, + type: this.type, + nsfw: this.nsfw, + parent: this.parent, + bitrate: this.bitrate, + userLimit: this.userLimit, + rateLimitPerUser: this.rateLimitPerUser, + position: this.position, + reason: null, + ...options, + }; return this.guild.channels.create(options.name, options); } /* eslint-enable max-len */ From ec5e9502a1f9e61738a8d91df9162e04d1d9735c Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Thu, 10 Jun 2021 17:53:38 +0200 Subject: [PATCH 2/2] refactor(GuildChannel): inline clone options spread --- src/structures/GuildChannel.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index b8e12341c354..043f36cfa678 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -573,7 +573,7 @@ class GuildChannel extends Channel { * @returns {Promise} */ clone(options = {}) { - options = { + return this.guild.channels.create(options.name, { name: this.name, permissionOverwrites: this.permissionOverwrites, topic: this.topic, @@ -586,8 +586,7 @@ class GuildChannel extends Channel { position: this.position, reason: null, ...options, - }; - return this.guild.channels.create(options.name, options); + }); } /* eslint-enable max-len */