blob: 93c9186eab501333ed134d095caaaac6c03e028d [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);
11 const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
Skyler Grey11236ba2022-08-08 21:13:33 +010012 await client.database.history.create("join", member.guild.id, member.user, null, null);
pineafan63fc5e22022-08-04 22:04:10 +010013 const data = {
14 meta: {
15 type: "memberJoin",
16 displayName: "Member Joined",
17 calculateType: "guildMemberUpdate",
18 color: NucleusColors.green,
19 emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
20 timestamp: member.joinedTimestamp
21 },
22 list: {
23 memberId: entry(member.id, `\`${member.id}\``),
24 name: entry(member.id, renderUser(member.user)),
25 joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
Skyler Grey11236ba2022-08-08 21:13:33 +010026 accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
pineafan63fc5e22022-08-04 22:04:10 +010027 serverMemberCount: member.guild.memberCount
28 },
29 hidden: {
30 guild: member.guild.id
pineafan32767212022-03-14 21:27:39 +000031 }
pineafan63fc5e22022-08-04 22:04:10 +010032 };
33 log(data);
pineafan32767212022-03-14 21:27:39 +000034}