fixed events/* (not including webhookUpdate.ts)
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 4731d58..936f8c2 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,4 +1,4 @@
-import type { GuildAuditLogsEntry, GuildMember } from "discord.js";
+import { AuditLogEvent, Guild, GuildAuditLogsEntry, GuildMember } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
import { purgeByUser } from "../actions/tickets/delete.js";
@@ -7,21 +7,21 @@
export const event = "guildMemberRemove";
export async function callback(client: NucleusClient, member: GuildMember) {
- purgeByUser(member.id, member.guild);
+ purgeByUser(member.id, member.guild.id);
await statsChannelRemove(client, member);
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
- const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === member.id).first();
+ const auditLog = (await getAuditLog(member.guild as Guild, AuditLogEvent.MemberKick))
+ .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === member.id)[0]!;
let type = "leave";
- if (audit) {
- if (audit.executor.id === client.user.id) return;
- if (audit.createdAt - 100 >= new Date().getTime()) {
+ if (auditLog) {
+ if (auditLog.executor!.id === client.user!.id) return;
+ if (auditLog.createdAt.valueOf() - 100 >= new Date().getTime()) {
type = "kick";
}
}
let data;
if (type === "kick") {
- await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+ await client.database.history.create("kick", member.guild.id, member.user, auditLog.executor, auditLog.reason);
data = {
meta: {
type: "memberKick",
@@ -34,11 +34,11 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ kickedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
+ reason: entry(auditLog.reason, auditLog.reason ? `\n> ${auditLog.reason}` : "*No reason provided.*"),
+ accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: member.guild.memberCount
},
hidden: {
@@ -59,9 +59,9 @@
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+ joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: member.guild.memberCount
},
hidden: {