blob: eb39cb9057ffe86983e3f9d042cba07666ac9b1b [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001import getEmojiByName from "../utils/getEmojiByName.js";
2
3export const event = 'emojiUpdate';
4
5export async function callback(client, oe, ne) {
pineafane625d782022-05-09 18:04:32 +01006 try {
7 const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
pineafan32767212022-03-14 21:27:39 +00008
pineafane625d782022-05-09 18:04:32 +01009 if (oe.name == ne.name) return
10 let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
11 let audit = auditLog.entries.first();
12 if (audit.executor.id == client.user.id) return;
pineafan32767212022-03-14 21:27:39 +000013
pineafane625d782022-05-09 18:04:32 +010014 let changes = {
15 id: entry(ne.id, `\`${ne.id}\``),
16 emoji: entry(ne.id, renderEmoji(ne)),
17 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
18 editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
19 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
20 }
21 let data = {
22 meta:{
23 type: 'emojiUpdate',
24 displayName: 'Emoji Edited',
25 calculateType: 'emojiUpdate',
26 color: NucleusColors.yellow,
27 emoji: "GUILD.EMOJI.EDIT",
28 timestamp: audit.createdTimestamp
29 },
30 list: changes,
31 hidden: {
32 guild: ne.guild.id
33 }
34 }
pineafan4edb7762022-06-26 19:21:04 +010035 log(data);
pineafane625d782022-05-09 18:04:32 +010036 } catch {}
pineafan32767212022-03-14 21:27:39 +000037}