PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 1 | import { AuditLogEvent } from 'discord.js'; |
| 2 | import type { NucleusClient } from "../utils/client.js"; |
| 3 | import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js' |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 4 | export const event = "emojiCreate"; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 5 | |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 6 | export async function callback(client: NucleusClient, emoji: GuildEmoji) { |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame^] | 7 | const { getAuditLog, log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger; |
| 8 | if (!await isLogging(emoji.guild.id, "emojiUpdate")) return; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 9 | const auditLog = (await getAuditLog(emoji.guild, AuditLogEvent.EmojiCreate)) |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame^] | 10 | .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0]; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 11 | if (!auditLog) return; |
| 12 | if (auditLog.executor!.id === client.user!.id) return; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 13 | const data = { |
| 14 | meta: { |
| 15 | type: "emojiCreate", |
| 16 | displayName: "Emoji Created", |
| 17 | calculateType: "emojiUpdate", |
| 18 | color: NucleusColors.green, |
| 19 | emoji: "GUILD.EMOJI.CREATE", |
| 20 | timestamp: emoji.createdTimestamp |
| 21 | }, |
| 22 | list: { |
| 23 | emojiId: entry(emoji.id, `\`${emoji.id}\``), |
| 24 | emoji: entry(emoji.name, renderEmoji(emoji)), |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 25 | createdBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)), |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 26 | created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 27 | }, |
| 28 | hidden: { |
| 29 | guild: emoji.guild.id |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 30 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 31 | }; |
| 32 | log(data); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 33 | } |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 34 | |