blob: a348b731cb067b44154ab1465f709d6db63fbcc3 [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) {
TheCodedProf6ec331b2023-02-20 12:13:06 -05007 const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
Skyler Greyda16adf2023-03-05 10:22:12 +00008 if (!(await isLogging(sticker.guild!.id, "stickerUpdate"))) return;
9 const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerDelete)).filter(
10 (entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id
11 )[0]!;
TheCodedProfa16d1672023-01-18 18:58:34 -050012 if (auditLog.executor!.id === client.user!.id) return;
pineafan63fc5e22022-08-04 22:04:10 +010013 const data = {
14 meta: {
15 type: "stickerDelete",
16 displayName: "Sticker Deleted",
17 calculateType: "stickerUpdate",
18 color: NucleusColors.red,
TheCodedProfff37b592023-02-20 15:09:02 -050019 emoji: "GUILD.EMOJI.DELETE",
TheCodedProf1807fb32023-02-20 14:33:48 -050020 timestamp: auditLog.createdTimestamp
pineafan63fc5e22022-08-04 22:04:10 +010021 },
22 list: {
TheCodedProfa16d1672023-01-18 18:58:34 -050023 stickerId: entry(sticker.id, `\`${sticker.id}\``),
24 sticker: entry(sticker.name, `\`${sticker.name}\``),
25 deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
26 created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp)),
27 deleted: entry(auditLog.createdTimestamp, renderDelta(auditLog.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010028 },
29 hidden: {
TheCodedProfa16d1672023-01-18 18:58:34 -050030 guild: sticker.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010031 }
pineafan63fc5e22022-08-04 22:04:10 +010032 };
33 log(data);
pineafanda6e5342022-07-03 10:03:16 +010034}