blob: 95dfde2513c08c30066e112eadf74a2eca1d39e0 [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";
PineaFan64486c42022-12-28 09:21:04 +00004import type { HaikuClient } from "../utils/haiku/index.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
pineafan0f5cc782022-08-12 21:55:42 +01008export async function callback(client: HaikuClient, member: GuildMember) {
9 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}