logging: fallbacks

This commit is contained in:
Cynthia Foxwell 2025-07-18 21:00:39 -06:00
parent b023d6cb8f
commit 0430a68f5a
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -164,6 +164,13 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
}); });
break; break;
} }
default: {
fields.push({
name: `\`${key}\``,
value,
inline: true,
});
}
} }
} }
@ -278,7 +285,7 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
} }
default: { default: {
fields.push({ fields.push({
name: key, name: `\`${key}\``,
value: formatChange(oldValue, newValue), value: formatChange(oldValue, newValue),
inline: true, inline: true,
}); });
@ -388,27 +395,43 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
const bot = hf.bot; const bot = hf.bot;
const target = bot.users.get(entry.targetID); const target = bot.users.get(entry.targetID);
const oldNickname = before?.nick; for (const [key, newValue] of Object.entries(after)) {
const newNickname = after?.nick; const oldValue = before[key];
switch (key) {
case "nick": {
if (oldValue != newValue) {
fields.push({
name: "Nickname",
value: formatChange(oldValue, newValue),
inline: true,
});
}
break;
}
case "communication_disabled_until": {
const isTimedOut = newValue != null;
const timeout = isTimedOut ? newValue : oldValue;
if (timeout != null) {
const timeoutDuration = new Date(timeout);
if (oldNickname != newNickname) { fields.push({
fields.push({ name: isTimedOut ? "Timed out until" : "Was timed out until",
name: "Nickname", value: `<t:${Math.round(timeoutDuration.getTime() / 1000)}>`,
value: formatChange(oldNickname, newNickname), inline: true,
inline: true, });
}); }
} break;
}
const isTimedOut = after?.communication_disabled_until != null; case "bypasses_verification":
const timeout = isTimedOut ? after?.communication_disabled_until : before?.communication_disabled_until; break;
if (timeout != null) { default: {
const timeoutDuration = new Date(timeout); fields.push({
name: `\`${key}\``,
fields.push({ value: formatChange(oldValue, newValue),
name: isTimedOut ? "Timed out until" : "Was timed out until", inline: true,
value: `<t:${Math.round(timeoutDuration.getTime() / 1000)}>`, });
inline: true, }
}); }
} }
let verb = "updated"; let verb = "updated";