blob: b01eb60fe7bfe2cdaefd1ff2d9908d9bc94e71d4 [file] [log] [blame]
pineafan0f5cc782022-08-12 21:55:42 +01001import type { GuildMember } from "discord.js";
pineafan63fc5e22022-08-04 22:04:10 +01002import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js";
3import { callback as welcome } from "../reflex/welcome.js";
PineaFan752af462022-12-31 21:59:38 +00004import type { NucleusClient } from "../utils/client.js";
pineafan6de4da52023-03-07 20:43:44 +00005import { doMemberChecks } from "../reflex/scanners.js";
pineafan4edb7762022-06-26 19:21:04 +01006
pineafan63fc5e22022-08-04 22:04:10 +01007export const event = "guildMemberAdd";
pineafan32767212022-03-14 21:27:39 +00008
PineaFan752af462022-12-31 21:59:38 +00009export async function callback(client: NucleusClient, member: GuildMember) {
Skyler Greyf4f21c42023-03-08 14:36:29 +000010 await welcome(member);
11 await statsChannelAdd(member.user, member.guild);
12 await doMemberChecks(member, member.guild);
TheCodedProf6ec331b2023-02-20 12:13:06 -050013 const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger;
Skyler Greyda16adf2023-03-05 10:22:12 +000014 if (!(await isLogging(member.guild.id, "guildMemberUpdate"))) return;
Skyler Grey11236ba2022-08-08 21:13:33 +010015 await client.database.history.create("join", member.guild.id, member.user, null, null);
pineafan63fc5e22022-08-04 22:04:10 +010016 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",
TheCodedProf6ec331b2023-02-20 12:13:06 -050023 timestamp: member.joinedTimestamp ?? Date.now()
pineafan63fc5e22022-08-04 22:04:10 +010024 },
25 list: {
26 memberId: entry(member.id, `\`${member.id}\``),
27 name: entry(member.id, renderUser(member.user)),
TheCodedProfa16d1672023-01-18 18:58:34 -050028 joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
29 accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp.valueOf()!)),
pineafan63fc5e22022-08-04 22:04:10 +010030 serverMemberCount: member.guild.memberCount
31 },
32 hidden: {
33 guild: member.guild.id
pineafan32767212022-03-14 21:27:39 +000034 }
pineafan63fc5e22022-08-04 22:04:10 +010035 };
Skyler Greyf4f21c42023-03-08 14:36:29 +000036 await log(data);
pineafan32767212022-03-14 21:27:39 +000037}