Another auditlog fix

This commit is contained in:
nolan 2021-06-21 14:55:28 -07:00
parent 6cf0217d22
commit 700ab8917a

View File

@ -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',