| import { AuditLogEvent } from 'discord.js'; |
| import type { NucleusClient } from "../utils/client.js"; |
| import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js' |
| export const event = "emojiCreate"; |
| |
| export async function callback(client: NucleusClient, emoji: GuildEmoji) { |
| const { getAuditLog, log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger; |
| if (!await isLogging(emoji.guild.id, "emojiUpdate")) return; |
| const auditLog = (await getAuditLog(emoji.guild, AuditLogEvent.EmojiCreate)) |
| .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0]; |
| if (!auditLog) return; |
| if (auditLog.executor!.id === client.user!.id) return; |
| const data = { |
| meta: { |
| type: "emojiCreate", |
| displayName: "Emoji Created", |
| calculateType: "emojiUpdate", |
| color: NucleusColors.green, |
| emoji: "GUILD.EMOJI.CREATE", |
| timestamp: emoji.createdTimestamp |
| }, |
| list: { |
| emojiId: entry(emoji.id, `\`${emoji.id}\``), |
| emoji: entry(emoji.name, renderEmoji(emoji)), |
| createdBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)), |
| created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)) |
| }, |
| hidden: { |
| guild: emoji.guild.id |
| } |
| }; |
| log(data); |
| } |
| |