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"; |
TheCodedProf | ff37b59 | 2023-02-20 15:09:02 -0500 | [diff] [blame] | 3 | import { generalException } from "../utils/createTemporaryStorage.js"; |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 4 | |
TheCodedProf | ff37b59 | 2023-02-20 15:09:02 -0500 | [diff] [blame] | 5 | export const event = "stickerCreate"; |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame] | 6 | |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 7 | export async function callback(client: NucleusClient, sticker: Sticker) { |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 8 | const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 9 | if (!(await isLogging(sticker.guild!.id, "stickerUpdate"))) return; |
| 10 | const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerCreate)).filter( |
| 11 | (entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id |
| 12 | )[0]!; |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 13 | if (auditLog.executor!.id === client.user!.id) return; |
TheCodedProf | ff37b59 | 2023-02-20 15:09:02 -0500 | [diff] [blame] | 14 | if (client.noLog.includes(`${sticker.guild!.id}${auditLog.id}`)) return; |
| 15 | generalException(`${sticker.guild!.id}${auditLog.id}`); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 16 | const data = { |
| 17 | meta: { |
| 18 | type: "stickerCreate", |
| 19 | displayName: "Sticker Created", |
| 20 | calculateType: "stickerUpdate", |
| 21 | color: NucleusColors.green, |
| 22 | emoji: "GUILD.EMOJI.CREATE", |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 23 | timestamp: sticker.createdTimestamp |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 24 | }, |
| 25 | list: { |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 26 | stickerId: entry(sticker.id, `\`${sticker.id}\``), |
| 27 | emoji: entry(sticker.name, `\`:${sticker.name}:\``), |
| 28 | createdBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)), |
| 29 | created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp)) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | }, |
| 31 | hidden: { |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 32 | guild: sticker.guild!.id |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 33 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 34 | }; |
Skyler Grey | f4f21c4 | 2023-03-08 14:36:29 +0000 | [diff] [blame^] | 35 | await log(data); |
pineafan | da6e534 | 2022-07-03 10:03:16 +0100 | [diff] [blame] | 36 | } |