Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 5dff86f..842a48b 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,72 +1,70 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
-export const event = 'guildMemberRemove'
+export const event = "guildMemberRemove";
export async function callback(client, member) {
- try { purgeByUser(member.id, member.guild); } catch {}
- try { await statsChannelRemove(client, member); } catch {}
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
- let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
- let audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
- let type = "leave"
- if (audit) {
- if (audit.executor.id === client.user.id) return
- if (audit.createdAt - 100 >= new Date().getTime()) {
- type = "kick"
- }
+ purgeByUser(member.id, member.guild);
+ await statsChannelRemove(client, member);
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
+ const audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
+ let type = "leave";
+ if (audit) {
+ if (audit.executor.id === client.user.id) return;
+ if (audit.createdAt - 100 >= new Date().getTime()) {
+ type = "kick";
}
- let data
- if (type === "kick") {
- try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
- data = {
- meta: {
- type: 'memberKick',
- displayName: 'Member Kicked',
- calculateType: 'guildMemberPunish',
- color: NucleusColors.red,
- emoji: "PUNISH.KICK.RED",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- 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)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
- }
+ }
+ let data;
+ if (type === "kick") {
+ await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+ data = {
+ meta: {
+ type: "memberKick",
+ displayName: "Member Kicked",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.red,
+ emoji: "PUNISH.KICK.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ 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)),
+ serverMemberCount: member.guild.memberCount
+ },
+ hidden: {
+ guild: member.guild.id
}
- } else {
- try { await client.database.history.create("leave", member.guild.id, member.user, null, null) } catch {}
- data = {
- meta: {
- type: 'memberLeave',
- displayName: 'Member Left',
- calculateType: 'guildMemberUpdate',
- color: NucleusColors.red,
- emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
- left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
- }
+ };
+ } else {
+ await client.database.history.create("leave", member.guild.id, member.user, null, null);
+ data = {
+ meta: {
+ type: "memberLeave",
+ displayName: "Member Left",
+ calculateType: "guildMemberUpdate",
+ color: NucleusColors.red,
+ emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+ left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount
+ },
+ hidden: {
+ guild: member.guild.id
}
- }
- log(data);
- } catch (e) { console.log(e) }
+ };
+ }
+ log(data);
}