blob: 66227d493b7b03f8114e4b105c445d4137055688 [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001export const event = "emojiUpdate";
pineafan32767212022-03-14 21:27:39 +00002
3export async function callback(client, oe, ne) {
Skyler Grey11236ba2022-08-08 21:13:33 +01004 const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
pineafan32767212022-03-14 21:27:39 +00005
pineafan63fc5e22022-08-04 22:04:10 +01006 if (oe.name === ne.name) return;
7 const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
8 const audit = auditLog.entries.first();
9 if (audit.executor.id === client.user.id) return;
pineafan32767212022-03-14 21:27:39 +000010
pineafan63fc5e22022-08-04 22:04:10 +010011 const changes = {
12 emojiId: entry(ne.id, `\`${ne.id}\``),
13 emoji: entry(ne.id, renderEmoji(ne)),
14 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
Skyler Grey11236ba2022-08-08 21:13:33 +010015 editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
pineafan63fc5e22022-08-04 22:04:10 +010016 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
17 };
18 const data = {
Skyler Grey75ea9172022-08-06 10:22:23 +010019 meta: {
pineafan63fc5e22022-08-04 22:04:10 +010020 type: "emojiUpdate",
21 displayName: "Emoji Edited",
22 calculateType: "emojiUpdate",
23 color: NucleusColors.yellow,
24 emoji: "GUILD.EMOJI.EDIT",
25 timestamp: audit.createdTimestamp
26 },
27 list: changes,
28 hidden: {
29 guild: ne.guild.id
pineafane625d782022-05-09 18:04:32 +010030 }
pineafan63fc5e22022-08-04 22:04:10 +010031 };
32 log(data);
Skyler Grey75ea9172022-08-06 10:22:23 +010033}