blob: 34b16de3ee50ab3015491db69582e9316dd2c802 [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 Grey75ea9172022-08-06 10:22:23 +01004 const {
5 getAuditLog,
6 log,
7 NucleusColors,
8 entry,
9 renderDelta,
10 renderUser,
11 renderEmoji
12 } = client.logger;
pineafan32767212022-03-14 21:27:39 +000013
pineafan63fc5e22022-08-04 22:04:10 +010014 if (oe.name === ne.name) return;
15 const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
16 const audit = auditLog.entries.first();
17 if (audit.executor.id === client.user.id) return;
pineafan32767212022-03-14 21:27:39 +000018
pineafan63fc5e22022-08-04 22:04:10 +010019 const changes = {
20 emojiId: entry(ne.id, `\`${ne.id}\``),
21 emoji: entry(ne.id, renderEmoji(ne)),
22 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
Skyler Grey75ea9172022-08-06 10:22:23 +010023 editedBy: entry(
24 audit.executor.id,
25 renderUser((await ne.guild.members.fetch(audit.executor.id)).user)
26 ),
pineafan63fc5e22022-08-04 22:04:10 +010027 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
28 };
29 const data = {
Skyler Grey75ea9172022-08-06 10:22:23 +010030 meta: {
pineafan63fc5e22022-08-04 22:04:10 +010031 type: "emojiUpdate",
32 displayName: "Emoji Edited",
33 calculateType: "emojiUpdate",
34 color: NucleusColors.yellow,
35 emoji: "GUILD.EMOJI.EDIT",
36 timestamp: audit.createdTimestamp
37 },
38 list: changes,
39 hidden: {
40 guild: ne.guild.id
pineafane625d782022-05-09 18:04:32 +010041 }
pineafan63fc5e22022-08-04 22:04:10 +010042 };
43 log(data);
Skyler Grey75ea9172022-08-06 10:22:23 +010044}