blob: a90de9aafb38f7ec6b319d035daec9b88d5c4ed2 [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
pineafane23c4ec2022-07-27 21:56:27 +01009 if (oe.name === ne.name) return
pineafane625d782022-05-09 18:04:32 +010010 let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
11 let audit = auditLog.entries.first();
pineafane23c4ec2022-07-27 21:56:27 +010012 if (audit.executor.id === client.user.id) return;
pineafan32767212022-03-14 21:27:39 +000013
pineafane625d782022-05-09 18:04:32 +010014 let changes = {
pineafanda6e5342022-07-03 10:03:16 +010015 emojiId: entry(ne.id, `\`${ne.id}\``),
pineafane625d782022-05-09 18:04:32 +010016 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}