blob: d123f44cbd2bfece9f8fd2ec372f7ca4a6b49e1b [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";
pineafan0f5cc782022-08-12 21:55:42 +01003
pineafan63fc5e22022-08-04 22:04:10 +01004export const event = "stickerDelete";
pineafanda6e5342022-07-03 10:03:16 +01005
TheCodedProfa16d1672023-01-18 18:58:34 -05006export async function callback(client: NucleusClient, sticker: Sticker) {
Samuel Shuert27bf3cd2023-03-03 15:51:25 -05007 const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
8 if (!await isLogging(sticker.guild!.id, "stickerUpdate")) return;
TheCodedProfa16d1672023-01-18 18:58:34 -05009 const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerDelete))
PineaFan638eb132023-01-19 10:41:22 +000010 .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
TheCodedProfa16d1672023-01-18 18:58:34 -050011 if (auditLog.executor!.id === client.user!.id) return;
pineafan63fc5e22022-08-04 22:04:10 +010012 const data = {
13 meta: {
14 type: "stickerDelete",
15 displayName: "Sticker Deleted",
16 calculateType: "stickerUpdate",
17 color: NucleusColors.red,
Samuel Shuert27bf3cd2023-03-03 15:51:25 -050018 emoji: "GUILD.EMOJI.DELETE",
TheCodedProfa16d1672023-01-18 18:58:34 -050019 timestamp: auditLog.createdTimestamp
pineafan63fc5e22022-08-04 22:04:10 +010020 },
21 list: {
TheCodedProfa16d1672023-01-18 18:58:34 -050022 stickerId: entry(sticker.id, `\`${sticker.id}\``),
23 sticker: entry(sticker.name, `\`${sticker.name}\``),
24 deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
25 created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp)),
26 deleted: entry(auditLog.createdTimestamp, renderDelta(auditLog.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010027 },
28 hidden: {
TheCodedProfa16d1672023-01-18 18:58:34 -050029 guild: sticker.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}