blob: 8023abcd9a10f6f4c65ceb9a0a6cd850b2e54a79 [file] [log] [blame]
PineaFane6ba7882023-01-18 20:41:16 +00001import { AuditLogEvent } from 'discord.js';
2import type { NucleusClient } from "../utils/client.js";
3import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js'
pineafan63fc5e22022-08-04 22:04:10 +01004export const event = "emojiCreate";
pineafan32767212022-03-14 21:27:39 +00005
PineaFane6ba7882023-01-18 20:41:16 +00006export async function callback(client: NucleusClient, emoji: GuildEmoji) {
7 const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger;
8 const auditLog = (await getAuditLog(emoji.guild, AuditLogEvent.EmojiCreate))
9 .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
10 if (!auditLog) return;
11 if (auditLog.executor!.id === client.user!.id) return;
pineafan63fc5e22022-08-04 22:04:10 +010012 const data = {
13 meta: {
14 type: "emojiCreate",
15 displayName: "Emoji Created",
16 calculateType: "emojiUpdate",
17 color: NucleusColors.green,
18 emoji: "GUILD.EMOJI.CREATE",
19 timestamp: emoji.createdTimestamp
20 },
21 list: {
22 emojiId: entry(emoji.id, `\`${emoji.id}\``),
23 emoji: entry(emoji.name, renderEmoji(emoji)),
PineaFane6ba7882023-01-18 20:41:16 +000024 createdBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
Skyler Grey11236ba2022-08-08 21:13:33 +010025 created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
pineafan63fc5e22022-08-04 22:04:10 +010026 },
27 hidden: {
28 guild: emoji.guild.id
pineafan32767212022-03-14 21:27:39 +000029 }
pineafan63fc5e22022-08-04 22:04:10 +010030 };
31 log(data);
pineafan32767212022-03-14 21:27:39 +000032}
PineaFane6ba7882023-01-18 20:41:16 +000033