fixed events/* (not including webhookUpdate.ts)
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index e74ad15..1ded432 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -1,4 +1,4 @@
-import type { GuildAuditLogsEntry, Invite } from "discord.js";
+import { AuditLogEvent, Guild, GuildAuditLogsEntry, GuildChannel, Invite } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
import type { NucleusClient } from "../utils/client.js";
@@ -6,12 +6,11 @@
export const event = "inviteDelete";
export async function callback(client: NucleusClient, invite: Invite) {
+ if(!invite.guild) return; // This is a DM invite (not a guild invite
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
- const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
- const audit = auditLog.entries
- .filter((entry: GuildAuditLogsEntry) => entry.target!.id === invite.inviterId)
- .first();
- if (audit.executor.id === client.user.id) return;
+ const auditLog = (await getAuditLog(invite.guild as Guild, AuditLogEvent.InviteDelete))
+ .filter((entry: GuildAuditLogsEntry) => (entry.target as Invite)!.code === invite.code)[0]!;
+ if (auditLog.executor!.id === client.user!.id) return;
const data = {
meta: {
type: "inviteDelete",
@@ -22,10 +21,10 @@
timestamp: new Date().getTime()
},
list: {
- channel: entry(invite.channel.id, renderChannel(invite.channel)),
+ channel: entry(invite.channel!.id, renderChannel(invite.channel as GuildChannel)),
link: entry(invite.url, invite.url),
expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
},
hidden: {