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 | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 4 | import type { NucleusClient } from "../utils/client.js"; |
pineafan | 6de4da5 | 2023-03-07 20:43:44 +0000 | [diff] [blame^] | 5 | import { doMemberChecks } from "../reflex/scanners.js"; |
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 | 752af46 | 2022-12-31 21:59:38 +0000 | [diff] [blame] | 9 | export async function callback(client: NucleusClient, member: GuildMember) { |
pineafan | 6de4da5 | 2023-03-07 20:43:44 +0000 | [diff] [blame^] | 10 | welcome(member); |
| 11 | statsChannelAdd(member.user, member.guild); |
| 12 | doMemberChecks(member, member.guild) |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 13 | const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 14 | if (!(await isLogging(member.guild.id, "guildMemberUpdate"))) return; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 15 | await client.database.history.create("join", member.guild.id, member.user, null, null); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 16 | const data = { |
| 17 | meta: { |
| 18 | type: "memberJoin", |
| 19 | displayName: "Member Joined", |
| 20 | calculateType: "guildMemberUpdate", |
| 21 | color: NucleusColors.green, |
| 22 | emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN", |
TheCodedProf | 6ec331b | 2023-02-20 12:13:06 -0500 | [diff] [blame] | 23 | timestamp: member.joinedTimestamp ?? Date.now() |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 24 | }, |
| 25 | list: { |
| 26 | memberId: entry(member.id, `\`${member.id}\``), |
| 27 | name: entry(member.id, renderUser(member.user)), |
TheCodedProf | a16d167 | 2023-01-18 18:58:34 -0500 | [diff] [blame] | 28 | joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)), |
| 29 | accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp.valueOf()!)), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | serverMemberCount: member.guild.memberCount |
| 31 | }, |
| 32 | hidden: { |
| 33 | guild: member.guild.id |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 34 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 35 | }; |
| 36 | log(data); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 37 | } |