forked from Galactic/galactic-bot
bugfix
This commit is contained in:
parent
fb0fe94ac2
commit
ccb07ad578
@ -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}>
|
||||
|
@ -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}`]
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user