This commit is contained in:
Erik 2022-07-18 22:01:06 +03:00
parent fb0fe94ac2
commit ccb07ad578
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 12 additions and 9 deletions

View File

@ -105,7 +105,6 @@ A thread was {action} in #{channel}
[MSGLOG_THREAD_DESC_CREATE]
**Thread:** {name} <#{id}>
**Owner:** {owner}
**Created by:** {actor}
[MSGLOG_THREAD_DESC_ARCHIVE]
**Thread:** {name} <#{id}>

View File

@ -108,23 +108,27 @@ class GuildLogger extends Observer {
}
let actor = null;
const auditLogPerm = guild.me.permissions.has('VIEW_AUDIT_LOG');
if (type === 'CREATE') actor = owner;
else if (type === 'DELETE') {
else if (type === 'DELETE' && auditLogPerm) {
const auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_DELETE', limit: 1 });
const log = auditLogs.entries.first();
if (thread.id !== log.target.id) return;
actor = log.executor;
} else if (['ARCHIVE', 'UNARCHIVE'].includes(type)) {
const auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_UPDATE', limit: 1 });
const log = auditLogs.entries.first();
if (log) {
if (thread.id !== log.target.id) return;
actor = log.executor;
}
if (!actor) return;
} else if (['ARCHIVE', 'UNARCHIVE'].includes(type) && auditLogPerm) {
const auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_UPDATE', limit: 1 });
const log = auditLogs.entries.first();
if (log) {
if (thread.id !== log.target.id) return;
actor = log.executor;
}
}
const embed = {
title: guild.format(`MSGLOG_THREAD_TITLE`, { action: guild.format('THREAD_SWITCH', { type }, { code: true }), channel: parent.name }),
description: guild.format(`MSGLOG_THREAD_DESC_${type}`, { owner: owner.tag, actor: actor.tag, name: thread.name, id: thread.id }),
description: guild.format(`MSGLOG_THREAD_DESC_${type}`, { owner: owner.tag, actor: actor?.tag || 'Unknown', name: thread.name, id: thread.id }),
footer: { text: guild.format('MSGLOG_THREAD_FOOTER', { ownerId: owner.id, channelId: parent.id, threadId: thread.id }) },
color: CONSTANTS.COLORS[`THREAD_${type}`]
};