blob: 0c395423d3885bcbf6d10e7121d7c778c7387e0b [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001export const event = 'emojiDelete'
2
3export async function callback(client, emoji) {
pineafane625d782022-05-09 18:04:32 +01004 try{
5 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
6 let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
pineafane23c4ec2022-07-27 21:56:27 +01007 let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
8 if (audit.executor.id === client.user.id) return;
pineafane625d782022-05-09 18:04:32 +01009 let data = {
10 meta: {
11 type: 'emojiDelete',
12 displayName: 'Emoji Deleted',
13 calculateType: 'emojiUpdate',
14 color: NucleusColors.red,
15 emoji: "GUILD.EMOJI.DELETE",
16 timestamp: audit.createdTimestamp,
17 },
18 list: {
pineafanda6e5342022-07-03 10:03:16 +010019 emojiId: entry(emoji.id, `\`${emoji.id}\``),
pineafane625d782022-05-09 18:04:32 +010020 emoji: entry(emoji.name, renderEmoji(emoji)),
21 deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
22 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
23 deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
24 },
25 hidden: {
26 guild: emoji.guild.id
27 }
pineafan32767212022-03-14 21:27:39 +000028 }
pineafan4edb7762022-06-26 19:21:04 +010029 log(data);
pineafane625d782022-05-09 18:04:32 +010030 } catch {}
pineafan32767212022-03-14 21:27:39 +000031}