blob: ea461ab6ead43ecd9e31e50875ee3388d885b9de [file] [log] [blame]
import humanizeDuration from 'humanize-duration';
import { purgeByUser } from '../automations/tickets/delete.js';
import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
export const event = 'guildMemberRemove'
export async function callback(_, member) {
try { await statsChannelRemove(_, member); } catch {}
try { purgeByUser(member.id, member.guild); } catch {} // TODO: add this to ban as well
try {
const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
let data = {
meta: {
type: 'memberLeave',
displayName: 'Member Left',
calculateType: 'guildMemberUpdate',
color: NucleusColors.red,
emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".LEAVE",
timestamp: new Date().getTime()
},
list: {
id: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
serverMemberCount: member.guild.memberCount,
},
hidden: {
guild: member.guild.id
}
}
log(data, member.client);
} catch {}
}