blob: bdfd99929633aaac3622c5109a455b7d26770e08 [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";
pineafan4edb7762022-06-26 19:21:04 +01005
pineafan63fc5e22022-08-04 22:04:10 +01006export const event = "guildMemberAdd";
pineafan32767212022-03-14 21:27:39 +00007
PineaFan752af462022-12-31 21:59:38 +00008export async function callback(client: NucleusClient, member: GuildMember) {
pineafan0f5cc782022-08-12 21:55:42 +01009 welcome(client, member);
10 statsChannelAdd(client, member);
TheCodedProf6ec331b2023-02-20 12:13:06 -050011 const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger;
Skyler Greyda16adf2023-03-05 10:22:12 +000012 if (!(await isLogging(member.guild.id, "guildMemberUpdate"))) return;
Skyler Grey11236ba2022-08-08 21:13:33 +010013 await client.database.history.create("join", member.guild.id, member.user, null, null);
pineafan63fc5e22022-08-04 22:04:10 +010014 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",
TheCodedProf6ec331b2023-02-20 12:13:06 -050021 timestamp: member.joinedTimestamp ?? Date.now()
pineafan63fc5e22022-08-04 22:04:10 +010022 },
23 list: {
24 memberId: entry(member.id, `\`${member.id}\``),
25 name: entry(member.id, renderUser(member.user)),
TheCodedProfa16d1672023-01-18 18:58:34 -050026 joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
27 accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp.valueOf()!)),
pineafan63fc5e22022-08-04 22:04:10 +010028 serverMemberCount: member.guild.memberCount
29 },
30 hidden: {
31 guild: member.guild.id
pineafan32767212022-03-14 21:27:39 +000032 }
pineafan63fc5e22022-08-04 22:04:10 +010033 };
34 log(data);
pineafan32767212022-03-14 21:27:39 +000035}