guildMemberAdd.ts

1import { Client, Events, GuildMember } from 'discord.js'
2import { Bot, Event } from '@/types/bot'
3import Logger from '@/classes/logger'
4import { discordConfig } from '@/configs/discord'
5
6export default {
7	name: Events.GuildMemberAdd,
8	once: false,
9	async execute(client: Bot<Client>, member: GuildMember) {
10		try {
11			await member.roles.add(discordConfig.memberRoleId)
12			Logger.log(
13				'info',
14				`Added member role to ${member.user.tag}`,
15				'MemberRole',
16			)
17		} catch (error: any) {
18			Logger.log(
19				'error',
20				`Failed to add member role to ${member.user.tag}: ${error.message}`,
21				'MemberRole',
22			)
23		}
24	},
25} as Event
26