PineaFan | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 1 | import type { NucleusClient } from "../utils/client.js"; |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 2 | import { AuditLogEvent, GuildAuditLogsEntry, Sticker } from "discord.js"; |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame] | 3 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 4 | export const event = "stickerDelete"; |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 5 | |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 6 | export async function callback(client: NucleusClient, sticker: Sticker) { |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame] | 7 | const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 8 | const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerDelete)) |
PineaFan | 638eb13 | 2023-01-19 10:41:22 +0000 | [diff] [blame] | 9 | .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!; |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 10 | if (auditLog.executor!.id === client.user!.id) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 11 | const data = { |
| 12 | meta: { |
| 13 | type: "stickerDelete", |
| 14 | displayName: "Sticker Deleted", |
| 15 | calculateType: "stickerUpdate", |
| 16 | color: NucleusColors.red, |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 17 | sticker: "GUILD.sticker.DELETE", |
| 18 | timestamp: auditLog.createdTimestamp |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 19 | }, |
| 20 | list: { |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 21 | stickerId: entry(sticker.id, `\`${sticker.id}\``), |
| 22 | sticker: entry(sticker.name, `\`${sticker.name}\``), |
| 23 | deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)), |
| 24 | created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp)), |
| 25 | deleted: entry(auditLog.createdTimestamp, renderDelta(auditLog.createdTimestamp)) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 26 | }, |
| 27 | hidden: { |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 28 | guild: sticker.guild!.id |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 29 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | }; |
| 31 | log(data); |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 32 | } |