| import type { NucleusClient } from "../utils/client.js"; |
| import { AuditLogEvent, GuildAuditLogsEntry, Sticker } from "discord.js"; |
| |
| export const event = "stickerUpdate"; |
| |
| export async function callback(client: NucleusClient, oldSticker: Sticker, newSticker: Sticker) { |
| const { getAuditLog, isLogging, log, NucleusColors, entry, renderDelta, renderUser } = client.logger; |
| if (!await isLogging(newSticker.guild!.id, "stickerUpdate")) return; |
| if (oldSticker.name === newSticker.name) return; |
| const auditLog = (await getAuditLog(newSticker.guild!, AuditLogEvent.StickerUpdate)) |
| .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === newSticker.id)[0]!; |
| if (auditLog.executor!.id === client.user!.id) return; |
| |
| const changes = { |
| stickerId: entry(newSticker.id, `\`${newSticker.id}\``), |
| edited: entry(newSticker.createdTimestamp, renderDelta(newSticker.createdTimestamp)), |
| editedBy: entry(auditLog.executor!.id, renderUser((await newSticker.guild!.members.fetch(auditLog.executor!.id)).user)), |
| name: entry([oldSticker.name, newSticker.name], `\`:${oldSticker.name}:\` -> \`:${newSticker.name}:\``) |
| }; |
| const data = { |
| meta: { |
| type: "stickerUpdate", |
| displayName: "Sticker Edited", |
| calculateType: "stickerUpdate", |
| color: NucleusColors.yellow, |
| emoji: "GUILD.EMOJI.EDIT", |
| timestamp: auditLog.createdTimestamp |
| }, |
| list: changes, |
| hidden: { |
| guild: newSticker.guild!.id |
| } |
| }; |
| log(data); |
| } |