blob: 295d48bd73ddf7ce576eaa08172cac55ddf0e85d [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";
pineafanda6e5342022-07-03 10:03:16 +01003
pineafan0f5cc782022-08-12 21:55:42 +01004export const event = "stickerDelete";
5
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_CREATE");
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: "stickerCreate",
14 displayName: "Sticker Created",
15 calculateType: "stickerUpdate",
16 color: NucleusColors.green,
17 emoji: "GUILD.EMOJI.CREATE",
18 timestamp: emoji.createdTimestamp
19 },
20 list: {
21 stickerId: entry(emoji.id, `\`${emoji.id}\``),
22 emoji: entry(emoji.name, `\`:${emoji.name}:\``),
23 createdBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010024 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010025 },
26 hidden: {
pineafan0f5cc782022-08-12 21:55:42 +010027 guild: emoji.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}