2023-05-23 01:14:17 -04:00
import Discord from 'discord.js' ;
2023-04-14 06:47:58 -04:00
import TClient from '../client.js' ;
2022-11-17 12:58:19 -05:00
2023-02-09 16:45:52 -05:00
function convert ( status? :Discord.ClientPresenceStatus ) {
2023-03-05 05:04:10 -05:00
if ( status ) return {
idle : '🟡' ,
dnd : '🔴' ,
online : '🟢'
} [ status ] ;
else return '⚫'
2022-11-17 12:58:19 -05:00
}
export default {
2023-03-05 05:04:10 -05:00
async run ( client : TClient , interaction : Discord.ChatInputCommandInteraction < 'cached' > ) {
2023-05-23 01:14:17 -04:00
const member = interaction . options . getMember ( 'member' ) as Discord . GuildMember ;
if ( member === null ) {
2023-03-05 05:04:10 -05:00
const user = interaction . options . getUser ( 'member' ) as Discord . User ;
const embed = new client . embed ( )
. setColor ( client . config . embedColor )
. setURL ( ` https://discord.com/users/ ${ user . id } ` )
. setThumbnail ( user . avatarURL ( { size :2048 } ) || user . defaultAvatarURL )
2023-06-09 21:11:19 -04:00
. setTitle ( ` ${ user . bot ? 'Bot' : 'User' } Info: ${ user . username } ` )
2023-03-05 05:04:10 -05:00
. setDescription ( ` <@ ${ user . id } > \ n \` ${ user . id } \` ` )
. addFields ( { name : '🔹 Account Creation Date' , value : ` <t: ${ Math . round ( user . createdTimestamp / 1000 ) } > \ n<t: ${ Math . round ( user . createdTimestamp / 1000 ) } :R> ` } )
interaction . reply ( { embeds : [ embed ] } )
} else {
await member . user . fetch ( ) ;
const presence = member . presence ? . clientStatus as Discord . ClientPresenceStatusData ;
const embedArray = [ ] ;
let title = 'Member' ;
if ( member . user . bot ) title = 'Bot' ;
else if ( member . user . id == interaction . guild . ownerId ) title = ':crown: Server Owner' ;
const embed = new client . embed ( )
. setColor ( member . displayColor || client . config . embedColor )
. setURL ( ` https://discord.com/users/ ${ member . user . id } ` )
. setThumbnail ( member . user . avatarURL ( { size :2048 } ) || member . user . defaultAvatarURL )
. setImage ( member . user . bannerURL ( { size :1024 } ) as string )
2023-06-09 21:11:19 -04:00
. setTitle ( ` ${ title } Info: ${ member . user . username } ` )
2023-03-05 05:04:10 -05:00
. setDescription ( ` <@ ${ member . user . id } > \ n \` ${ member . user . id } \` ` )
. addFields (
{ name : '🔹 Account Creation Date' , value : ` <t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } > \ n<t: ${ Math . round ( member . user . createdTimestamp / 1000 ) } :R> ` } ,
{ name : '🔹 Server Join Date' , value : ` <t: ${ Math . round ( ( member . joinedTimestamp as number ) / 1000 ) } > \ n<t: ${ Math . round ( ( member . joinedTimestamp as number ) / 1000 ) } :R> ` } ,
{ name : ` 🔹 Roles: ${ member . roles . cache . size - 1 } ` , value : member.roles.cache.size > 1 ? member . roles . cache . filter ( x = > x . id !== interaction . guild . roles . everyone . id ) . sort ( ( a , b ) = > b . position - a . position ) . map ( x = > x ) . join ( member . roles . cache . size > 4 ? ' ' : '\n' ) . slice ( 0 , 1024 ) : 'No roles' }
)
if ( member . premiumSinceTimestamp !== null ) embed . addFields ( { name : '🔹 Server Boosting since' , value : ` <t: ${ Math . round ( member . premiumSinceTimestamp / 1000 ) } > \ n<t: ${ Math . round ( member . premiumSinceTimestamp / 1000 ) } :R> ` , inline : true } )
2023-05-23 01:14:17 -04:00
if ( ! presence ) embed . addFields ( { name : ` 🔹 Status: Unavailable to be fetched ` , value : '\u200b' } )
2023-03-05 05:04:10 -05:00
if ( member . presence ) embed . addFields ( { name : ` 🔹 Status: ${ member . presence . status } ` , value : ` ${ member . presence . status === 'offline' ? '⚫' : ` Desktop: ${ convert ( presence . desktop ) } \ nWeb: ${ convert ( presence . web ) } \ nMobile: ${ convert ( presence . mobile ) } ` } ` , inline : true } )
embedArray . push ( embed )
interaction . reply ( { embeds : embedArray } )
}
} ,
2023-05-23 01:14:17 -04:00
data : new Discord . SlashCommandBuilder ( )
2023-03-05 05:04:10 -05:00
. setName ( 'whois' )
. setDescription ( 'View your own or someone else\'s information' )
2023-05-23 01:14:17 -04:00
. addUserOption ( x = > x
2023-03-05 05:04:10 -05:00
. setName ( 'member' )
. setDescription ( 'Member or user to view their information' )
. setRequired ( true ) )
2022-11-17 12:58:19 -05:00
}