blob: 76bb6f1a3d588e66a2207032dfea469697b7fde9 [file] [log] [blame]
pineafan0f5cc782022-08-12 21:55:42 +01001// @ts-expect-error
Skyler Greyf21323a2022-08-13 23:58:22 +01002import type { HaikuClient } from "jshaiku";
pineafan0f5cc782022-08-12 21:55:42 +01003import type { GuildAuditLogsEntry, Sticker } from "discord.js";
pineafanda6e5342022-07-03 10:03:16 +01004
pineafan0f5cc782022-08-12 21:55:42 +01005export const event = "stickerDelete";
6
7export async function callback(client: HaikuClient, emoji: Sticker) {
8 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
pineafan63fc5e22022-08-04 22:04:10 +01009 const auditLog = await getAuditLog(emoji.guild, "STICKER_CREATE");
pineafan0f5cc782022-08-12 21:55:42 +010010 const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === emoji.id).first();
pineafan63fc5e22022-08-04 22:04:10 +010011 if (audit.executor.id === client.user.id) return;
12 const data = {
13 meta: {
14 type: "stickerCreate",
15 displayName: "Sticker Created",
16 calculateType: "stickerUpdate",
17 color: NucleusColors.green,
18 emoji: "GUILD.EMOJI.CREATE",
19 timestamp: emoji.createdTimestamp
20 },
21 list: {
22 stickerId: entry(emoji.id, `\`${emoji.id}\``),
23 emoji: entry(emoji.name, `\`:${emoji.name}:\``),
24 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010025 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010026 },
27 hidden: {
pineafan0f5cc782022-08-12 21:55:42 +010028 guild: emoji.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010029 }
pineafan63fc5e22022-08-04 22:04:10 +010030 };
31 log(data);
pineafanda6e5342022-07-03 10:03:16 +010032}