2022-11-15 09:06:18 -05:00
import Discord from 'discord.js' ;
2023-04-14 06:47:58 -04:00
import TClient from '../client.js' ;
2023-12-24 10:21:40 -05:00
export default class GuildMemberAdd {
2024-01-06 04:49:35 -05:00
static async run ( client :TClient , member :Discord.GuildMember ) {
2023-12-24 10:21:40 -05:00
if ( member . partial || member . guild ? . id != client . config . dcServer . id ) return ;
2024-03-25 07:23:02 -04:00
const memberCount = member . guild . memberCount ;
const suffix = {
2024-03-23 21:36:12 -04:00
one : 'st' ,
two : 'nd' ,
few : 'rd' ,
other : 'th'
2024-03-25 07:23:02 -04:00
} [ new Intl . PluralRules ( 'en' , { type : 'ordinal' } ) . select ( memberCount ) ] ;
2024-03-23 21:36:12 -04:00
2023-06-09 21:11:19 -04:00
let isBot = 'Bot' ;
if ( ! member . user . bot ) isBot = 'Member' ;
2023-03-05 05:04:10 -05:00
if ( ! client . config . botSwitches . logs ) return ;
2024-03-25 07:23:02 -04:00
( client . channels . resolve ( client . config . dcServer . channels . welcome ) as Discord . TextChannel ) . send ( { embeds : [ new client . embed ( ) . setColor ( client . config . embedColor ) . setThumbnail ( member . user . displayAvatarURL ( { size : 2048 } ) || member . user . defaultAvatarURL ) . setTitle ( ` Welcome to ${ member . guild . name } , ${ member . user . username } ! ` ) . setFooter ( { text : ` ${ memberCount } ${ suffix } member ` } ) ] } ) ;
2024-01-31 15:54:38 -05:00
2023-03-05 05:04:10 -05:00
const newInvites = await member . guild . invites . fetch ( ) ;
2023-05-23 01:14:17 -04:00
const usedInvite = newInvites . find ( ( inv :Discord.Invite ) = > client . invites . get ( inv . code ) ? . uses < inv . uses ) ;
newInvites . forEach ( ( inv :Discord.Invite ) = > client . invites . set ( inv . code , { uses : inv.uses , creator : inv.inviterId , channel : inv.channel.name } ) ) ;
2024-03-04 19:03:04 -05:00
( client . channels . resolve ( client . config . dcServer . channels . bot_log ) as Discord . TextChannel ) . send ( { embeds : [
2024-03-25 07:23:02 -04:00
new client . embed ( ) . setColor ( client . config . embedColorGreen ) . setTimestamp ( ) . setThumbnail ( member . user . displayAvatarURL ( { size : 2048 } ) ) . setTitle ( ` ${ isBot } Joined: ${ member . user . username } ` ) . setFooter ( { text : ` Total members: ${ memberCount } ${ suffix } | ID: ${ member . user . id } ` } ) . addFields (
2023-03-05 05:04:10 -05:00
{ name : '🔹 Account Creation Date' , value : ` <t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } > \ n<t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } :R> ` } ,
2023-06-09 21:11:19 -04:00
{ name : '🔹 Invite Data:' , value : usedInvite ? ` Invite: \` ${ usedInvite . code } \` \ nCreated by: ** ${ usedInvite . inviter ? . username } ** \ nChannel: **# ${ usedInvite . channel . name } ** ` : 'No invite data could be fetched.' }
) ] } ) ;
2023-03-05 05:04:10 -05:00
}
2022-11-25 04:46:51 -05:00
}