blob: ea461ab6ead43ecd9e31e50875ee3388d885b9de [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001import humanizeDuration from 'humanize-duration';
pineafan377794f2022-04-18 19:01:01 +01002import { purgeByUser } from '../automations/tickets/delete.js';
pineafan32767212022-03-14 21:27:39 +00003import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
4
5export const event = 'guildMemberRemove'
6
7export async function callback(_, member) {
8 try { await statsChannelRemove(_, member); } catch {}
pineafan377794f2022-04-18 19:01:01 +01009 try { purgeByUser(member.id, member.guild); } catch {} // TODO: add this to ban as well
pineafan32767212022-03-14 21:27:39 +000010 try {
11 const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
12 let data = {
13 meta: {
14 type: 'memberLeave',
15 displayName: 'Member Left',
16 calculateType: 'guildMemberUpdate',
17 color: NucleusColors.red,
18 emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".LEAVE",
19 timestamp: new Date().getTime()
20 },
21 list: {
22 id: entry(member.id, `\`${member.id}\``),
23 name: entry(member.id, renderUser(member.user)),
24 joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
25 left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
26 timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
27 accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
28 serverMemberCount: member.guild.memberCount,
29 },
30 hidden: {
31 guild: member.guild.id
32 }
33 }
34 log(data, member.client);
35 } catch {}
36}