import type { TextChannel } from "discord.js"; import { Client, Discord, On, type ArgsOf } from "discordx"; @Discord() export class MemberEvents { @On({ event: "guildMemberAdd" }) async memberAdd([member]: ArgsOf<"guildMemberAdd">, client: Client) { const channel = client.channels.cache.get(Bun.env.WELCOME!) as TextChannel; await channel.send( `Welcome to **${member.guild.name}** <@${member.user.id}> ! You are member #${member.guild.memberCount}! Get a color role and Operating System role(s) in the Channels & Roles section if you want and enjoy your stay <3`, ); if (member.user.bot) { const botRole = member.guild.roles.cache.get(Bun.env.BOT_ROLE!); if (botRole) { await member.roles.add(botRole); } } } @On({ event: "guildMemberRemove" }) async memberRemove([member]: ArgsOf<"guildMemberRemove">, client: Client) { const channel = client.channels.cache.get(Bun.env.GOODBYE!) as TextChannel; await channel.send(`We're sad to see you go, ${member.user.username}.`); } @On({ event: "guildMemberUpdate" }) async memberUpdate([_, newM]: ArgsOf<"guildMemberUpdate">) { if (newM.roles.cache.get(Bun.env.BAD_ROLE!)) { await newM.ban({ reason: "youngin", }); } } }