pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 1 | // @ts-expect-error |
| 2 | import type { HaikuClient } from "jshaiku" |
| 3 | import type { GuildAuditLogsEntry, Sticker } from "discord.js"; |
| 4 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 5 | export const event = "stickerDelete"; |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 6 | |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 7 | export async function callback(client: HaikuClient, emoji: Sticker) { |
| 8 | const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 9 | const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE"); |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 10 | const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === emoji.id).first(); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 11 | if (audit.executor.id === client.user.id) return; |
| 12 | const data = { |
| 13 | meta: { |
| 14 | type: "stickerDelete", |
| 15 | displayName: "Sticker Deleted", |
| 16 | calculateType: "stickerUpdate", |
| 17 | color: NucleusColors.red, |
| 18 | emoji: "GUILD.EMOJI.DELETE", |
| 19 | timestamp: audit.createdTimestamp |
| 20 | }, |
| 21 | list: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | stickerId: entry(emoji.id, `\`${emoji.id}\``), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 23 | sticker: entry(emoji.name, `\`${emoji.name}\``), |
| 24 | deletedBy: entry(audit.executor.id, renderUser(audit.executor)), |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 25 | created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)), |
| 26 | deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 27 | }, |
| 28 | hidden: { |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 29 | guild: emoji.guild!.id |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 30 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 31 | }; |
| 32 | log(data); |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 33 | } |