blob: b341ae9d859911030695764f6e6200576876f1db [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";
pineafanda6e5342022-07-03 10:03:16 +01003
pineafan0f5cc782022-08-12 21:55:42 +01004export const event = "stickerDelete";
5
TheCodedProfa16d1672023-01-18 18:58:34 -05006export async function callback(client: NucleusClient, sticker: Sticker) {
pineafan0f5cc782022-08-12 21:55:42 +01007 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
TheCodedProfa16d1672023-01-18 18:58:34 -05008 const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.EmojiCreate))
PineaFan638eb132023-01-19 10:41:22 +00009 .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
TheCodedProfa16d1672023-01-18 18:58:34 -050010 if (auditLog.executor!.id === client.user!.id) return;
pineafan63fc5e22022-08-04 22:04:10 +010011 const data = {
12 meta: {
13 type: "stickerCreate",
14 displayName: "Sticker Created",
15 calculateType: "stickerUpdate",
16 color: NucleusColors.green,
17 emoji: "GUILD.EMOJI.CREATE",
TheCodedProfa16d1672023-01-18 18:58:34 -050018 timestamp: sticker.createdTimestamp
pineafan63fc5e22022-08-04 22:04:10 +010019 },
20 list: {
TheCodedProfa16d1672023-01-18 18:58:34 -050021 stickerId: entry(sticker.id, `\`${sticker.id}\``),
22 emoji: entry(sticker.name, `\`:${sticker.name}:\``),
23 createdBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
24 created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010025 },
26 hidden: {
TheCodedProfa16d1672023-01-18 18:58:34 -050027 guild: sticker.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010028 }
pineafan63fc5e22022-08-04 22:04:10 +010029 };
30 log(data);
pineafanda6e5342022-07-03 10:03:16 +010031}