pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame^] | 1 | import humanizeDuration from 'humanize-duration'; |
| 2 | import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js'; |
| 3 | |
| 4 | export const event = 'guildMemberRemove' |
| 5 | |
| 6 | export async function callback(_, member) { |
| 7 | try { await statsChannelRemove(_, member); } catch {} |
| 8 | try { |
| 9 | const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger |
| 10 | let data = { |
| 11 | meta: { |
| 12 | type: 'memberLeave', |
| 13 | displayName: 'Member Left', |
| 14 | calculateType: 'guildMemberUpdate', |
| 15 | color: NucleusColors.red, |
| 16 | emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".LEAVE", |
| 17 | timestamp: new Date().getTime() |
| 18 | }, |
| 19 | list: { |
| 20 | id: entry(member.id, `\`${member.id}\``), |
| 21 | name: entry(member.id, renderUser(member.user)), |
| 22 | joined: entry(member.joinedAt, renderDelta(member.joinedAt)), |
| 23 | left: entry(new Date().getTime(), renderDelta(new Date().getTime())), |
| 24 | timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })), |
| 25 | accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)), |
| 26 | serverMemberCount: member.guild.memberCount, |
| 27 | }, |
| 28 | hidden: { |
| 29 | guild: member.guild.id |
| 30 | } |
| 31 | } |
| 32 | log(data, member.client); |
| 33 | } catch {} |
| 34 | } |