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