blob: c4b15352fbead5150e2bb1e3b29ccc27b75c487c [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001export const event = "emojiDelete";
pineafan32767212022-03-14 21:27:39 +00002
3export async function callback(client, emoji) {
Skyler Grey11236ba2022-08-08 21:13:33 +01004 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
pineafan63fc5e22022-08-04 22:04:10 +01005 const auditLog = await getAuditLog(emoji.guild, "EMOJI_DELETE");
Skyler Grey11236ba2022-08-08 21:13:33 +01006 const audit = auditLog.entries.filter((entry) => entry.target.id === emoji.id).first();
pineafan63fc5e22022-08-04 22:04:10 +01007 if (audit.executor.id === client.user.id) return;
8 const data = {
9 meta: {
10 type: "emojiDelete",
11 displayName: "Emoji Deleted",
12 calculateType: "emojiUpdate",
13 color: NucleusColors.red,
14 emoji: "GUILD.EMOJI.DELETE",
15 timestamp: audit.createdTimestamp
16 },
17 list: {
18 emojiId: entry(emoji.id, `\`${emoji.id}\``),
19 emoji: entry(emoji.name, renderEmoji(emoji)),
20 deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
Skyler Grey11236ba2022-08-08 21:13:33 +010021 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
22 deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010023 },
24 hidden: {
25 guild: emoji.guild.id
pineafan32767212022-03-14 21:27:39 +000026 }
pineafan63fc5e22022-08-04 22:04:10 +010027 };
28 log(data);
pineafan32767212022-03-14 21:27:39 +000029}