blob: 786c4ecd598ee1e1a15e79f16a87582ef60f31c9 [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";
pineafan0f5cc782022-08-12 21:55:42 +01004// @ts-expect-error
5import type { HaikuClient } from "jshaiku";
pineafan4edb7762022-06-26 19:21:04 +01006
pineafan63fc5e22022-08-04 22:04:10 +01007export const event = "guildMemberAdd";
pineafan32767212022-03-14 21:27:39 +00008
pineafan0f5cc782022-08-12 21:55:42 +01009export async function callback(client: HaikuClient, member: GuildMember) {
10 welcome(client, member);
11 statsChannelAdd(client, member);
12 const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
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",
21 timestamp: member.joinedTimestamp
22 },
23 list: {
24 memberId: entry(member.id, `\`${member.id}\``),
25 name: entry(member.id, renderUser(member.user)),
26 joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
Skyler Grey11236ba2022-08-08 21:13:33 +010027 accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
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}