logging: thread tags
This commit is contained in:
parent
70dbc62394
commit
9dcc211fd9
1 changed files with 49 additions and 5 deletions
|
@ -200,6 +200,7 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
|
||||||
value: `<#${entry.target.parentID}> (${
|
value: `<#${entry.target.parentID}> (${
|
||||||
entry.guild.channels.get(entry.target.parentID)?.name ?? "<uncached>"
|
entry.guild.channels.get(entry.target.parentID)?.name ?? "<uncached>"
|
||||||
})`,
|
})`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x),
|
||||||
footer: {
|
footer: {
|
||||||
|
@ -212,6 +213,41 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AuditLogActions.THREAD_UPDATE: {
|
case AuditLogActions.THREAD_UPDATE: {
|
||||||
|
const parentChannel = entry.guild.channels.get(entry.target.parentID);
|
||||||
|
|
||||||
|
let tagDiff;
|
||||||
|
if (entry.after.applied_tags != null) {
|
||||||
|
const newTags = new Set(entry.after.applied_tags);
|
||||||
|
const oldTags = new Set(entry.before.applied_tags ?? []);
|
||||||
|
|
||||||
|
let addedTags = Array.from(newTags.difference(oldTags));
|
||||||
|
let removedTags = Array.from(oldTags.difference(newTags));
|
||||||
|
|
||||||
|
if (parentChannel != null) {
|
||||||
|
addedTags = addedTags.map((id) => {
|
||||||
|
const tag = parentChannel.availableTags.find((t) => t.id === id);
|
||||||
|
|
||||||
|
return tag != null ? `${tag.emojiName} ${tag.name}` : id;
|
||||||
|
});
|
||||||
|
removedTags = removedTags.map((id) => {
|
||||||
|
const tag = parentChannel.availableTags.find((t) => t.id === id);
|
||||||
|
|
||||||
|
return tag != null ? `${tag.emojiName} ${tag.name}` : id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tagDiff = "```diff\n";
|
||||||
|
|
||||||
|
if (addedTags.length > 0) tagDiff += "+ " + addedTags.join("\n+ ");
|
||||||
|
|
||||||
|
if (removedTags.length > 0) {
|
||||||
|
if (addedTags.length > 0) tagDiff += "\n";
|
||||||
|
tagDiff += "- " + removedTags.join("\n- ");
|
||||||
|
}
|
||||||
|
|
||||||
|
tagDiff += "```";
|
||||||
|
}
|
||||||
|
|
||||||
channel
|
channel
|
||||||
.createMessage({
|
.createMessage({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -240,20 +276,27 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
|
||||||
entry.after.name != null && {
|
entry.after.name != null && {
|
||||||
name: "Name",
|
name: "Name",
|
||||||
value: `\`${entry.before.name}\` -> \`${entry.after.name}\``,
|
value: `\`${entry.before.name}\` -> \`${entry.after.name}\``,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
entry.target?.parentID != null && {
|
||||||
|
name: "Parent Channel",
|
||||||
|
value: `<#${entry.target.parentID}> (${parentChannel?.name ?? "<uncached>"})`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
entry.after.auto_archive_duration != null && {
|
entry.after.auto_archive_duration != null && {
|
||||||
name: "Hide After Inactivity",
|
name: "Hide After Inactivity",
|
||||||
value: `\`${entry.before.auto_archive_duration}\` -> \`${entry.after.auto_archive_duration}\``,
|
value: `\`${entry.before.auto_archive_duration}\` -> \`${entry.after.auto_archive_duration}\``,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
entry.after.rate_limit_per_user != null && {
|
entry.after.rate_limit_per_user != null && {
|
||||||
name: "Slowmode",
|
name: "Slowmode",
|
||||||
value: `\`${entry.before.rate_limit_per_user}\` -> \`${entry.after.rate_limit_per_user}\``,
|
value: `\`${entry.before.rate_limit_per_user}\` -> \`${entry.after.rate_limit_per_user}\``,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
entry.target?.parentID != null && {
|
tagDiff != null && {
|
||||||
name: "Parent Channel",
|
name: "Tags",
|
||||||
value: `<#${entry.target.parentID}> (${
|
value: tagDiff,
|
||||||
entry.guild.channels.get(entry.target.parentID)?.name ?? "<uncached>"
|
inline: false,
|
||||||
})`,
|
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x),
|
||||||
footer: {
|
footer: {
|
||||||
|
@ -285,6 +328,7 @@ events.add("guildAuditLogEntryCreate", "logging", async function (entry) {
|
||||||
value: `<#${entry.target.parentID}> (${
|
value: `<#${entry.target.parentID}> (${
|
||||||
entry.guild.channels.get(entry.target.parentID)?.name ?? "<uncached>"
|
entry.guild.channels.get(entry.target.parentID)?.name ?? "<uncached>"
|
||||||
})`,
|
})`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x),
|
||||||
footer: {
|
footer: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue