blob: bc8adb85ae2332a6ac06a8c9bd0af70a41bed93b [file] [log] [blame]
PineaFan752af462022-12-31 21:59:38 +00001import type { NucleusClient } from "../utils/client.js";
TheCodedProfa16d1672023-01-18 18:58:34 -05002import { AuditLogEvent, GuildAuditLogsEntry, Sticker } from "discord.js";
TheCodedProfff37b592023-02-20 15:09:02 -05003import { generalException } from "../utils/createTemporaryStorage.js";
pineafanda6e5342022-07-03 10:03:16 +01004
TheCodedProfff37b592023-02-20 15:09:02 -05005export const event = "stickerCreate";
pineafan0f5cc782022-08-12 21:55:42 +01006
TheCodedProfa16d1672023-01-18 18:58:34 -05007export async function callback(client: NucleusClient, sticker: Sticker) {
TheCodedProf6ec331b2023-02-20 12:13:06 -05008 const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
Skyler Greyda16adf2023-03-05 10:22:12 +00009 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]!;
TheCodedProfa16d1672023-01-18 18:58:34 -050013 if (auditLog.executor!.id === client.user!.id) return;
TheCodedProfff37b592023-02-20 15:09:02 -050014 if (client.noLog.includes(`${sticker.guild!.id}${auditLog.id}`)) return;
15 generalException(`${sticker.guild!.id}${auditLog.id}`);
pineafan63fc5e22022-08-04 22:04:10 +010016 const data = {
17 meta: {
18 type: "stickerCreate",
19 displayName: "Sticker Created",
20 calculateType: "stickerUpdate",
21 color: NucleusColors.green,
22 emoji: "GUILD.EMOJI.CREATE",
TheCodedProfa16d1672023-01-18 18:58:34 -050023 timestamp: sticker.createdTimestamp
pineafan63fc5e22022-08-04 22:04:10 +010024 },
25 list: {
TheCodedProfa16d1672023-01-18 18:58:34 -050026 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))
pineafan63fc5e22022-08-04 22:04:10 +010030 },
31 hidden: {
TheCodedProfa16d1672023-01-18 18:58:34 -050032 guild: sticker.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010033 }
pineafan63fc5e22022-08-04 22:04:10 +010034 };
Skyler Greyf4f21c42023-03-08 14:36:29 +000035 await log(data);
pineafanda6e5342022-07-03 10:03:16 +010036}