bugfix
This commit is contained in:
parent
b23f6b9a98
commit
faa0abbd82
@ -83,10 +83,9 @@ class AuditLogObserver extends Observer {
|
||||
// console.log(oldMember.communicationDisabledUntilTimestamp, newMember.communicationDisabledUntilTimestamp);
|
||||
const now = Date.now();
|
||||
const mute = newMember.communicationDisabledUntilTimestamp !== null;
|
||||
const auditLogs = await wrapper.fetchAuditLogs({ limit: 1, type: 'MEMBER_UPDATE' });
|
||||
if (!auditLogs.entries.size) return undefined;
|
||||
const entry = await this._fetchFirstEntry(wrapper, newMember.user, 'MEMBER_UPDATE', 'communication_disabled_until');
|
||||
|
||||
const entry = auditLogs.entries.find((e) => e.changes?.some((e) => e.key === 'communication_disabled_until'));
|
||||
// const entry = auditLogs.entries.find((e) => e.changes?.some((e) => e.key === 'communication_disabled_until'));
|
||||
if (!entry) return undefined; // || newMember.communicationDisabledUntilTimestamp < now
|
||||
|
||||
let type = null,
|
||||
@ -147,12 +146,14 @@ class AuditLogObserver extends Observer {
|
||||
}).handle();
|
||||
}
|
||||
|
||||
async _fetchFirstEntry(guild, user, type) {
|
||||
async _fetchFirstEntry(guild, user, type, subtype = null) {
|
||||
if (!guild.me.permissions.has('VIEW_AUDIT_LOG')) return null;
|
||||
const audit = await guild.fetchAuditLogs({ limit: 1, type });
|
||||
if (audit.entries.size === 0) return null;
|
||||
|
||||
const entry = audit.entries.filter((e) => e?.target?.id === user.id).first();
|
||||
const entry = audit.entries.filter((e) => e?.target?.id === user.id &&
|
||||
subtype ? e.changes.some((e) => e.key === subtype) : true).first();
|
||||
|
||||
if (!entry || entry.executor.id === this.client.user.id) return null;
|
||||
if (entry.target.id !== user.id) return null;
|
||||
if (entry.action !== type) return null;
|
||||
|
Loading…
Reference in New Issue
Block a user