pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 1 | import type { GuildMember } from "discord.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 2 | import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js"; |
| 3 | import { callback as welcome } from "../reflex/welcome.js"; |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 4 | // @ts-expect-error |
| 5 | import type { HaikuClient } from "jshaiku"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 6 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 7 | export const event = "guildMemberAdd"; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 8 | |
pineafan | 0f5cc78 | 2022-08-12 21:55:42 +0100 | [diff] [blame^] | 9 | export async function callback(client: HaikuClient, member: GuildMember) { |
| 10 | welcome(client, member); |
| 11 | statsChannelAdd(client, member); |
| 12 | const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 13 | await client.database.history.create("join", member.guild.id, member.user, null, null); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 14 | const data = { |
| 15 | meta: { |
| 16 | type: "memberJoin", |
| 17 | displayName: "Member Joined", |
| 18 | calculateType: "guildMemberUpdate", |
| 19 | color: NucleusColors.green, |
| 20 | emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN", |
| 21 | timestamp: member.joinedTimestamp |
| 22 | }, |
| 23 | list: { |
| 24 | memberId: entry(member.id, `\`${member.id}\``), |
| 25 | name: entry(member.id, renderUser(member.user)), |
| 26 | joined: entry(member.joinedAt, renderDelta(member.joinedAt)), |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 27 | accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 28 | serverMemberCount: member.guild.memberCount |
| 29 | }, |
| 30 | hidden: { |
| 31 | guild: member.guild.id |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 32 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 33 | }; |
| 34 | log(data); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 35 | } |