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]
|
[MSGLOG_THREAD_DESC_CREATE]
|
||||||
**Thread:** {name} <#{id}>
|
**Thread:** {name} <#{id}>
|
||||||
**Owner:** {owner}
|
**Owner:** {owner}
|
||||||
**Created by:** {actor}
|
|
||||||
|
|
||||||
[MSGLOG_THREAD_DESC_ARCHIVE]
|
[MSGLOG_THREAD_DESC_ARCHIVE]
|
||||||
**Thread:** {name} <#{id}>
|
**Thread:** {name} <#{id}>
|
||||||
|
@ -108,23 +108,27 @@ class GuildLogger extends Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let actor = null;
|
let actor = null;
|
||||||
|
const auditLogPerm = guild.me.permissions.has('VIEW_AUDIT_LOG');
|
||||||
if (type === 'CREATE') actor = owner;
|
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 auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_DELETE', limit: 1 });
|
||||||
const log = auditLogs.entries.first();
|
const log = auditLogs.entries.first();
|
||||||
if (thread.id !== log.target.id) return;
|
if (log) {
|
||||||
actor = log.executor;
|
if (thread.id !== log.target.id) return;
|
||||||
} else if (['ARCHIVE', 'UNARCHIVE'].includes(type)) {
|
actor = log.executor;
|
||||||
|
}
|
||||||
|
} else if (['ARCHIVE', 'UNARCHIVE'].includes(type) && auditLogPerm) {
|
||||||
const auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_UPDATE', limit: 1 });
|
const auditLogs = await guild.fetchAuditLogs({ type: 'THREAD_UPDATE', limit: 1 });
|
||||||
const log = auditLogs.entries.first();
|
const log = auditLogs.entries.first();
|
||||||
if (thread.id !== log.target.id) return;
|
if (log) {
|
||||||
actor = log.executor;
|
if (thread.id !== log.target.id) return;
|
||||||
|
actor = log.executor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!actor) return;
|
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: guild.format(`MSGLOG_THREAD_TITLE`, { action: guild.format('THREAD_SWITCH', { type }, { code: true }), channel: parent.name }),
|
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 }) },
|
footer: { text: guild.format('MSGLOG_THREAD_FOOTER', { ownerId: owner.id, channelId: parent.id, threadId: thread.id }) },
|
||||||
color: CONSTANTS.COLORS[`THREAD_${type}`]
|
color: CONSTANTS.COLORS[`THREAD_${type}`]
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user