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' ;
2022-11-15 09:06:18 -05:00
export default {
2023-03-05 05:04:10 -05:00
async run ( client :TClient , member :Discord.GuildMember ) {
2023-03-08 04:04:52 -05:00
if ( member . partial || member . guild ? . id != client . config . mainServer . id ) return ;
const index = member . guild . memberCount ;
const suffix = ( ( index ) = > {
const numbers = index . toString ( ) . split ( '' ) . reverse ( ) ; // eg 1850 --> [0,5,8,1]
if ( numbers [ 1 ] === '1' ) return 'th' ; // this is some -teen
else {
if ( numbers [ 0 ] === '1' ) return 'st' ;
else if ( numbers [ 0 ] === '2' ) return 'nd' ;
else if ( numbers [ 0 ] === '3' ) return 'rd' ;
else return 'th' ;
}
} ) ( index ) ;
2023-03-05 05:04:10 -05:00
( client . channels . resolve ( client . config . mainServer . 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 Daggerwin, ${ member . user . tag } ! ` ) . setFooter ( { text : ` ${ index } ${ suffix } member ` } ) ] } )
if ( ! client . config . botSwitches . logs ) return ;
const newInvites = await member . guild . invites . fetch ( ) ;
const usedInvite = newInvites . find ( ( inv :any ) = > client . invites . get ( inv . code ) ? . uses < inv . uses ) ;
newInvites . forEach ( ( inv :any ) = > client . invites . set ( inv . code , { uses : inv.uses , creator : inv.inviter.id } ) ) ;
( client . channels . resolve ( client . config . mainServer . channels . logs ) as Discord . TextChannel ) . send ( { embeds : [
new client . embed ( ) . setColor ( client . config . embedColorGreen ) . setTimestamp ( ) . setThumbnail ( member . user . displayAvatarURL ( { size : 2048 } ) ) . setTitle ( ` Member Joined: ${ member . user . tag } ` ) . setDescription ( ` <@ ${ member . user . id } > \ n \` ${ member . user . id } \` ` ) . setFooter ( { text : ` Total members: ${ index } ${ suffix } ` } ) . addFields (
{ name : '🔹 Account Creation Date' , value : ` <t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } > \ n<t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } :R> ` } ,
{ name : '🔹 Invite Data:' , value : usedInvite ? ` Invite: \` ${ usedInvite . code } \` \ nCreated by: ** ${ usedInvite . inviter ? . tag } ** ` : 'No invite data could be found.' }
) ] } )
}
2022-11-25 04:46:51 -05:00
}