| import type { NucleusClient } from "../utils/client.js"; |
| import { AuditLogEvent, GuildAuditLogsEntry, Sticker } from "discord.js"; |
| |
| export const event = "stickerDelete"; |
| |
| export async function callback(client: NucleusClient, sticker: Sticker) { |
| const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
| if (!await isLogging(sticker.guild!.id, "stickerUpdate")) return; |
| const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerDelete)) |
| .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!; |
| if (auditLog.executor!.id === client.user!.id) return; |
| const data = { |
| meta: { |
| type: "stickerDelete", |
| displayName: "Sticker Deleted", |
| calculateType: "stickerUpdate", |
| color: NucleusColors.red, |
| emoji: "GUILD.STICKER.DELETE", |
| timestamp: auditLog.createdTimestamp |
| }, |
| list: { |
| stickerId: entry(sticker.id, `\`${sticker.id}\``), |
| sticker: entry(sticker.name, `\`${sticker.name}\``), |
| deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)), |
| created: entry(sticker.createdTimestamp, renderDelta(sticker.createdTimestamp)), |
| deleted: entry(auditLog.createdTimestamp, renderDelta(auditLog.createdTimestamp)) |
| }, |
| hidden: { |
| guild: sticker.guild!.id |
| } |
| }; |
| log(data); |
| } |