blob: c9b3fab129951d232a72e458b9fa60856d54a38b [file] [log] [blame]
pineafan0f5cc782022-08-12 21:55:42 +01001// @ts-expect-error
2import type { HaikuClient } from "jshaiku"
3import type { GuildAuditLogsEntry, Sticker } from "discord.js";
4
pineafan63fc5e22022-08-04 22:04:10 +01005export const event = "stickerDelete";
pineafanda6e5342022-07-03 10:03:16 +01006
pineafan0f5cc782022-08-12 21:55:42 +01007export 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_DELETE");
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: "stickerDelete",
15 displayName: "Sticker Deleted",
16 calculateType: "stickerUpdate",
17 color: NucleusColors.red,
18 emoji: "GUILD.EMOJI.DELETE",
19 timestamp: audit.createdTimestamp
20 },
21 list: {
Skyler Grey75ea9172022-08-06 10:22:23 +010022 stickerId: entry(emoji.id, `\`${emoji.id}\``),
pineafan63fc5e22022-08-04 22:04:10 +010023 sticker: entry(emoji.name, `\`${emoji.name}\``),
24 deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010025 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
26 deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010027 },
28 hidden: {
pineafan0f5cc782022-08-12 21:55:42 +010029 guild: emoji.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010030 }
pineafan63fc5e22022-08-04 22:04:10 +010031 };
32 log(data);
pineafanda6e5342022-07-03 10:03:16 +010033}