2022-11-15 09:06:18 -05:00
import Discord from 'discord.js' ;
2023-01-27 21:33:55 -05:00
import TClient from '../client' ;
2022-11-15 09:06:18 -05:00
export default {
2023-01-02 04:45:05 -05:00
async run ( client :TClient , interaction :Discord.ChatInputCommandInteraction ) {
2022-11-15 09:06:18 -05:00
if ( ! interaction . inGuild ( ) || ! interaction . inCachedGuild ( ) || ! interaction . command ) return ;
if ( interaction . isCommand ( ) ) {
2023-01-28 05:04:52 -05:00
let Sub :string
try {
Sub = ` ${ interaction . options . getSubcommand ( ) } `
} catch ( e ) {
Sub = ''
}
2022-11-15 09:06:18 -05:00
const commandFile = client . commands . get ( interaction . commandName ) ;
2023-01-28 05:04:52 -05:00
console . log ( ` [ ${ client . moment ( ) . format ( 'DD/MM/YY HH:mm:ss' ) } ] ${ interaction . user . tag } used / ${ interaction . commandName } ${ Sub } in # ${ interaction . channel . name } ` ) ;
2023-01-01 20:09:03 -05:00
if ( ! client . config . botSwitches . commands && ! client . config . eval . whitelist . includes ( interaction . user . id ) ) return interaction . reply ( { content : 'Bot is currently being run in development mode.' , ephemeral : true } ) ;
2022-11-15 09:06:18 -05:00
if ( commandFile ) {
try {
2022-11-16 13:53:42 -05:00
commandFile . default . run ( client , interaction ) ;
2022-11-15 09:06:18 -05:00
commandFile . uses ? commandFile . uses ++ : commandFile . uses = 1 ;
2022-11-28 01:33:20 -05:00
} catch ( error ) {
2022-11-24 19:28:46 -05:00
console . log ( ` An error occured while running command " ${ commandFile . name } " ` , error , error . stack ) ;
2022-11-18 22:23:33 -05:00
return interaction . reply ( 'An error occured while executing that command.' ) ;
2022-11-15 09:06:18 -05:00
}
}
}
}
}