blob: fed99e69a58e73e86c367bc16b8ab44cd47f0590 [file] [log] [blame]
PineaFan752af462022-12-31 21:59:38 +00001import type { NucleusClient } from "../utils/client.js";
pineafan0f5cc782022-08-12 21:55:42 +01002import type { GuildAuditLogsEntry, Sticker } from "discord.js";
3
pineafan63fc5e22022-08-04 22:04:10 +01004export const event = "stickerDelete";
pineafanda6e5342022-07-03 10:03:16 +01005
PineaFan752af462022-12-31 21:59:38 +00006export async function callback(client: NucleusClient, emoji: Sticker) {
pineafan0f5cc782022-08-12 21:55:42 +01007 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
pineafan63fc5e22022-08-04 22:04:10 +01008 const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE");
pineafan0f5cc782022-08-12 21:55:42 +01009 const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === emoji.id).first();
pineafan63fc5e22022-08-04 22:04:10 +010010 if (audit.executor.id === client.user.id) return;
11 const data = {
12 meta: {
13 type: "stickerDelete",
14 displayName: "Sticker Deleted",
15 calculateType: "stickerUpdate",
16 color: NucleusColors.red,
17 emoji: "GUILD.EMOJI.DELETE",
18 timestamp: audit.createdTimestamp
19 },
20 list: {
Skyler Grey75ea9172022-08-06 10:22:23 +010021 stickerId: entry(emoji.id, `\`${emoji.id}\``),
pineafan63fc5e22022-08-04 22:04:10 +010022 sticker: entry(emoji.name, `\`${emoji.name}\``),
23 deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010024 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
25 deleted: entry(audit.createdTimestamp, renderDelta(audit.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}