From 700ab8917a858e24366df69852fddf5c87959695 Mon Sep 17 00:00:00 2001 From: nolan Date: Mon, 21 Jun 2021 14:55:28 -0700 Subject: [PATCH] Another auditlog fix --- structure/client/components/observers/AuditLog.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/structure/client/components/observers/AuditLog.js b/structure/client/components/observers/AuditLog.js index b863b02..da68c70 100644 --- a/structure/client/components/observers/AuditLog.js +++ b/structure/client/components/observers/AuditLog.js @@ -27,6 +27,7 @@ class AuditLogObserver extends Observer { const settings = await guild.settings(); if(!settings.moderationLog.channel || !settings.moderationLog.infractions.includes('BAN')) return undefined; //This is checked by the infraction handling, but it may save resources if checked earlier. const audit = await this._fetchFirstEntry(guild, user, 'MEMBER_BAN_ADD'); + if(!audit) return undefined; new Infraction(this.client, { type: 'BAN', targetType: 'USER', @@ -41,6 +42,7 @@ class AuditLogObserver extends Observer { const settings = await guild.settings(); if(!settings.moderationLog.channel || !settings.moderationLog.infractions.includes('UNBAN')) return undefined; //This is checked by the infraction handling, but it may save resources if checked earlier. const audit = await this._fetchFirstEntry(guild, user, 'MEMBER_BAN_REMOVE'); + if(!audit) return undefined; new Infraction(this.client, { type: 'UNBAN', targetType: 'USER', @@ -55,6 +57,7 @@ class AuditLogObserver extends Observer { const settings = await member.guild.settings(); if(!settings.moderationLog.channel || !settings.moderationLog.infractions.includes('KICK')) return undefined; //This is checked by the infraction handling, but it may save resources if checked earlier. const audit = await this._fetchFirstEntry(member.guild, member.user, 'MEMBER_KICK'); + if(!audit) return undefined; new Infraction(this.client, { type: 'KICK', targetType: 'USER', @@ -77,6 +80,7 @@ class AuditLogObserver extends Observer { if(!oldMember.roles.cache.has(mutedRole) && newMember.roles.cache.has(mutedRole)) { //Member was assigned muted role. if(!settings.moderationLog.infractions.includes('MUTE')) return undefined; const audit = await this._fetchFirstEntry(newMember.guild, newMember.user, 'MEMBER_ROLE_UPDATE'); + if(!audit) return undefined; new Infraction(this.client, { type: 'MUTE', targetType: 'USER', @@ -85,10 +89,10 @@ class AuditLogObserver extends Observer { executor: audit.executor, reason: "*This action was performed without the bot.*" }).handle(); - } else if(oldMember.roles.cache.has(mutedRole) && !newMember.roles.cache.has(mutedRole)) { //Member was unassigned muted role. if(!settings.moderationLog.infractions.includes('UNMUTE')) return undefined; const audit = await this._fetchFirstEntry(newMember.guild, newMember.user, 'MEMBER_ROLE_UPDATE'); + if(!audit) return undefined; new Infraction(this.client, { type: 'UNMUTE', targetType: 'USER',