From f72ce7c136cf2dfe31a67b190c00e30ba7d70bfa Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sat, 10 Jul 2021 14:15:20 +0200 Subject: [PATCH] fix(GuildChannel): clone its PermissionOverwriteManager too (#6083) --- src/managers/PermissionOverwriteManager.js | 8 +++++++- src/structures/GuildChannel.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/managers/PermissionOverwriteManager.js b/src/managers/PermissionOverwriteManager.js index 91c3e03ceb63..87902e7460a5 100644 --- a/src/managers/PermissionOverwriteManager.js +++ b/src/managers/PermissionOverwriteManager.js @@ -13,13 +13,19 @@ const { OverwriteTypes } = require('../util/Constants'); */ class PermissionOverwriteManager extends CachedManager { constructor(channel, iterable) { - super(channel.client, PermissionOverwrites, iterable); + super(channel.client, PermissionOverwrites); /** * The channel of the permission overwrite this manager belongs to * @type {GuildChannel} */ this.channel = channel; + + if (iterable) { + for (const item of iterable) { + this._add(item); + } + } } /** diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index f5c049969068..24616ec218e2 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -90,6 +90,12 @@ class GuildChannel extends Channel { } } + _clone() { + const clone = super._clone(); + clone.permissionOverwrites = new PermissionOverwriteManager(clone, this.permissionOverwrites.cache.values()); + return clone; + } + /** * The category parent of this channel * @type {?CategoryChannel}