blob: 2566fed846855cf256c9bbf13e8a17f383732495 [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) {
6 const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
7
8 if (oe.name == ne.name) return
9 let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
10 let audit = auditLog.entries.first();
11 if (audit.executor.id == client.user.id) return;
12
13 let changes = {
14 id: entry(ne.id, `\`${ne.id}\``),
15 emoji: entry(ne.id, renderEmoji(ne)),
16 edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
17 editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
18 name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
19 }
20 let data = {
21 meta:{
22 type: 'emojiUpdate',
23 displayName: 'Emoji Edited',
24 calculateType: 'emojiUpdate',
25 color: NucleusColors.yellow,
26 emoji: "GUILD.EMOJI.EDIT",
27 timestamp: audit.createdTimestamp
28 },
29 list: changes,
30 hidden: {
31 guild: ne.guild.id
32 }
33 }
34 log(data, client);
35}