Bug fixes and ~~performance~~ typing improvements
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index d170396..00f6d84 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -6,12 +6,9 @@
export async function callback(client, member) {
purgeByUser(member.id, member.guild);
await statsChannelRemove(client, member);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } =
- member.client.logger;
+ 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();
+ 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;
@@ -21,13 +18,7 @@
}
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, audit.executor, audit.reason);
data = {
meta: {
type: "memberKick",
@@ -41,21 +32,10 @@
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())
- ),
+ 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)
- ),
+ 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: {
@@ -63,13 +43,7 @@
}
};
} else {
- await client.database.history.create(
- "leave",
- member.guild.id,
- member.user,
- null,
- null
- );
+ await client.database.history.create("leave", member.guild.id, member.user, null, null);
data = {
meta: {
type: "memberLeave",
@@ -82,18 +56,9 @@
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)
- ),
+ 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: {