2024-04-02 04:02:22 +01:00
const api = require ( "../helpers/api" ) ;
2024-04-08 10:56:28 +01:00
const { api _role _id , auth _url } = require ( "../config" ) ;
const { SlashCommandBuilder , EmbedBuilder } = require ( "discord.js" ) ;
2024-04-02 04:02:22 +01:00
module . exports = {
2024-04-08 10:56:28 +01:00
data : new SlashCommandBuilder ( )
. setName ( "info" )
. setDescription ( "Check your hosting info" ) ,
async run ( interaction ) {
const deferOptions = { ephemeral : true } ;
await interaction . deferReply ( deferOptions ) ;
const footerText = { text : "Coded by @onurcansevinc" } ;
const authorText = { name : "Your Account's Information" } ;
const thumbnailOptions = { dynamic : true } ;
let infoEmbed = new EmbedBuilder ( )
. setTimestamp ( )
. setColor ( "Random" )
. setFooter ( footerText )
. setAuthor ( authorText )
. setThumbnail ( interaction . guild . iconURL ( thumbnailOptions ) )
. setDescription ( ` You have not yet connected your Discord account to the hosting panel! \n Click [here]( ${ auth _url } ) to link your Discord account to the hosting panel! ` ) ;
const noLinkReply = { embeds : [ infoEmbed ] } ;
if ( ! interaction . member . roles . cache . has ( api _role _id ) ) {
return interaction . editReply ( noLinkReply ) ;
2024-04-02 04:02:22 +01:00
}
2024-04-08 10:56:28 +01:00
let discordUser = await api . getDiscordUser ( interaction . user . id ) ;
const noDiscordUserReply = { embeds : [ infoEmbed ] } ;
if ( ! discordUser ) {
return interaction . editReply ( noDiscordUserReply ) ;
2024-04-02 04:02:22 +01:00
}
2024-04-08 10:56:28 +01:00
let user = await api . getUser ( discordUser . data [ 0 ] . email ) ;
const noUserReply = { embeds : [ infoEmbed ] } ;
if ( ! user ) {
return interaction . editReply ( noUserReply ) ;
2024-04-02 04:02:22 +01:00
}
2024-04-08 10:56:28 +01:00
user = user . data [ 0 ] ;
let infoString = '' ;
infoString += ` - **ID:** ${ user . id } \n ` ;
infoString += ` - **Balance:** $ ${ user . balance } \n ` ;
infoString += ` - **Status:** ${ user . status === "active" ? "🟢 Active" : "🔴 Passive" } \n ` ;
infoString += ` - **Created:** <t: ${ new Date ( user . created _at ) / 1000 } :R> \n ` ;
infoString += ` - **Last Login:** <t: ${ new Date ( user . last _login _at ) / 1000 } :R> \n ` ;
infoEmbed . setDescription ( infoString ) ;
const userInfoReply = { embeds : [ infoEmbed ] } ;
return interaction . editReply ( userInfoReply ) ;
2024-04-02 04:02:22 +01:00
}
2024-04-08 10:56:28 +01:00
} ;