From 0c0d65ee24dac3b9ec278665ad70c454dc804c99 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 8 Jul 2022 22:00:08 +0300 Subject: [PATCH] bugfix --- src/structure/components/infractions/Ban.js | 4 ++-- src/structure/components/observers/UtilityHook.js | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/structure/components/infractions/Ban.js b/src/structure/components/infractions/Ban.js index f750d4c..dfa9875 100644 --- a/src/structure/components/infractions/Ban.js +++ b/src/structure/components/infractions/Ban.js @@ -72,8 +72,8 @@ class BanInfraction extends Infraction { } async resolve(...args) { - const member = await this.guild.memberWrapper(this.targetId); - const callback = await member.getCallback(this.type); + const infraction = await this.client.moderationManager.findLatestInfraction(this.type, this.targetId); + const callback = this.client.moderationManager.callbacks.get(infraction.id); if (callback) this.client.moderationManager.removeCallback(callback); const banned = await this.guild.bans.fetch(this.targetId).catch(() => null); diff --git a/src/structure/components/observers/UtilityHook.js b/src/structure/components/observers/UtilityHook.js index 627422d..db620e3 100644 --- a/src/structure/components/observers/UtilityHook.js +++ b/src/structure/components/observers/UtilityHook.js @@ -58,14 +58,19 @@ class UtilityHook extends Observer { guild: guild.id, target: member.id, type: 'MUTE', - _callbacked: false + _callbacked: false, + resolved: false }); if (!infraction || infraction.resolved) return; + const role = await guild.resolveRole(setting.role); - if (infraction.data.muteType === 0) await member.roles.add(setting.role, 'automute upon rejoin, type 0'); - else if (infraction.data.muteType === 1) { + if (infraction.data.muteType === 0) { + if (!role) return; + await member.roles.add(setting.role, 'automute upon rejoin, type 0'); + } else if (infraction.data.muteType === 1) { + if (!role) return; await Util.wait(5 * 1000); //wait 5 seconds in case other bots add roles that would break the mute const roles = member.roles.cache; const managed = roles.find((r) => r.managed);