blob: c6e3b6e1a838595adc1b3b8befac8974d1cd3118 [file] [log] [blame]
pineafan0f5cc782022-08-12 21:55:42 +01001// @ts-expect-error
2import type { HaikuClient } from "jshaiku"
3import type { Sticker } from "discord.js";
4
pineafan63fc5e22022-08-04 22:04:10 +01005export const event = "stickerUpdate";
pineafanda6e5342022-07-03 10:03:16 +01006
pineafan0f5cc782022-08-12 21:55:42 +01007export async function callback(client: HaikuClient, oe: Sticker, ne: Sticker) {
Skyler Grey11236ba2022-08-08 21:13:33 +01008 const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
pineafanda6e5342022-07-03 10:03:16 +01009
pineafan63fc5e22022-08-04 22:04:10 +010010 if (oe.name === ne.name) return;
pineafan0f5cc782022-08-12 21:55:42 +010011 const auditLog = await getAuditLog(ne.guild, "STICKER_UPDATE");
pineafan63fc5e22022-08-04 22:04:10 +010012 const audit = auditLog.entries.first();
13 if (audit.executor.id === client.user.id) return;
pineafanda6e5342022-07-03 10:03:16 +010014
pineafan63fc5e22022-08-04 22:04:10 +010015 const changes = {
Skyler Grey75ea9172022-08-06 10:22:23 +010016 stickerId: entry(ne.id, `\`${ne.id}\``),
pineafan63fc5e22022-08-04 22:04:10 +010017 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
pineafan0f5cc782022-08-12 21:55:42 +010018 editedBy: entry(audit.executor.id, renderUser((await ne.guild!.members.fetch(audit.executor.id)).user)),
pineafan63fc5e22022-08-04 22:04:10 +010019 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
20 };
21 const data = {
Skyler Grey75ea9172022-08-06 10:22:23 +010022 meta: {
pineafan63fc5e22022-08-04 22:04:10 +010023 type: "stickerUpdate",
24 displayName: "Sticker Edited",
25 calculateType: "stickerUpdate",
26 color: NucleusColors.yellow,
27 emoji: "GUILD.EMOJI.EDIT",
28 timestamp: audit.createdTimestamp
29 },
30 list: changes,
31 hidden: {
pineafan0f5cc782022-08-12 21:55:42 +010032 guild: ne.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010033 }
pineafan63fc5e22022-08-04 22:04:10 +010034 };
35 log(data);
Skyler Grey75ea9172022-08-06 10:22:23 +010036}