blob: 1421ec21cac89acd837737c3a6d0186cf37972ae [file] [log] [blame]
PineaFan64486c42022-12-28 09:21:04 +00001import type { HaikuClient } from "../utils/haiku/index.js";
pineafan0f5cc782022-08-12 21:55:42 +01002import type { Sticker } from "discord.js";
3
pineafan63fc5e22022-08-04 22:04:10 +01004export const event = "stickerUpdate";
pineafanda6e5342022-07-03 10:03:16 +01005
pineafan0f5cc782022-08-12 21:55:42 +01006export async function callback(client: HaikuClient, oe: Sticker, ne: Sticker) {
Skyler Grey11236ba2022-08-08 21:13:33 +01007 const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
pineafanda6e5342022-07-03 10:03:16 +01008
pineafan63fc5e22022-08-04 22:04:10 +01009 if (oe.name === ne.name) return;
pineafan0f5cc782022-08-12 21:55:42 +010010 const auditLog = await getAuditLog(ne.guild, "STICKER_UPDATE");
pineafan63fc5e22022-08-04 22:04:10 +010011 const audit = auditLog.entries.first();
12 if (audit.executor.id === client.user.id) return;
pineafanda6e5342022-07-03 10:03:16 +010013
pineafan63fc5e22022-08-04 22:04:10 +010014 const changes = {
Skyler Grey75ea9172022-08-06 10:22:23 +010015 stickerId: entry(ne.id, `\`${ne.id}\``),
pineafan63fc5e22022-08-04 22:04:10 +010016 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
pineafan0f5cc782022-08-12 21:55:42 +010017 editedBy: entry(audit.executor.id, renderUser((await ne.guild!.members.fetch(audit.executor.id)).user)),
pineafan63fc5e22022-08-04 22:04:10 +010018 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
19 };
20 const data = {
Skyler Grey75ea9172022-08-06 10:22:23 +010021 meta: {
pineafan63fc5e22022-08-04 22:04:10 +010022 type: "stickerUpdate",
23 displayName: "Sticker Edited",
24 calculateType: "stickerUpdate",
25 color: NucleusColors.yellow,
26 emoji: "GUILD.EMOJI.EDIT",
27 timestamp: audit.createdTimestamp
28 },
29 list: changes,
30 hidden: {
pineafan0f5cc782022-08-12 21:55:42 +010031 guild: ne.guild!.id
pineafanda6e5342022-07-03 10:03:16 +010032 }
pineafan63fc5e22022-08-04 22:04:10 +010033 };
34 log(data);
Skyler Grey75ea9172022-08-06 10:22:23 +010035}