From 1cc33adb88991ee79753e636731394a8a5707f1b Mon Sep 17 00:00:00 2001 From: nolan Date: Fri, 11 Jun 2021 23:45:06 -0700 Subject: [PATCH] Mutes should now retain removed roles if the mute is overwritten. --- structure/moderation/infractions/Mute.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/structure/moderation/infractions/Mute.js b/structure/moderation/infractions/Mute.js index 0a7a932..1e13be6 100644 --- a/structure/moderation/infractions/Mute.js +++ b/structure/moderation/infractions/Mute.js @@ -74,10 +74,15 @@ class MuteInfraction extends Infraction { muteRole: role ? role.id : null }; //Info will be saved in database and into the callback when resolved. - const callbacks = this.client.moderationManager.callbacks.filter((c) => c.infraction.type === 'MUTE' - && c.infraction.target === this.target.id); + const callback = this.client.moderationManager.callbacks.filter((c) => c.infraction.type === 'MUTE' + && c.infraction.target === this.target.id).first(); + + if(callback) { + this.data.removedRoles = [...new Set([...this.data.removedRoles, ...callback.infraction.data.removedRoles])]; + this.client.moderationManager._removeExpiration(callback); + } - if(callbacks.size > 0) callbacks.map((c) => this.client.moderationManager._removeExpiration(c)); + // if(callbacks.size > 0) callbacks.map((c) => this.client.moderationManager._removeExpiration(c)); await this.handle(); return this._succeed();