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
run ( client :TClient , interaction :Discord.BaseInteraction ) {
2023-02-13 02:37:23 -05:00
if ( ! interaction . inGuild ( ) || ! interaction . inCachedGuild ( ) ) return ;
if ( interaction . isChatInputCommand ( ) ) {
const commandFile = client . commands . get ( interaction . commandName ) ;
2023-02-24 19:55:11 -05:00
console . log ( client . logTime ( ) , ` ${ interaction . user . tag } used / ${ interaction . commandName } ${ interaction . options . getSubcommand ( false ) ? ? '' } in # ${ interaction . channel . name } ` ) ;
2023-05-02 00:19:05 -04:00
if ( ! client . config . botSwitches . commands && ! client . config . whitelist . includes ( interaction . user . id ) ) return interaction . reply ( { content : 'Bot is currently being run in development mode.' , ephemeral : true } ) ;
2023-02-13 02:37:23 -05:00
if ( commandFile ) {
try {
2023-04-14 06:47:58 -04:00
commandFile . command . default . run ( client , interaction ) ;
2023-03-05 05:04:10 -05:00
commandFile . uses ? commandFile . uses ++ : commandFile . uses = 1 ;
2023-02-13 02:37:23 -05:00
} catch ( error ) {
2023-03-31 04:56:01 -04:00
console . log ( ` An error occurred while running command " ${ interaction . commandName } ${ interaction . options . getSubcommand ( false ) ? ? '' } " ` , error , error . stack ) ;
return interaction . reply ( 'An error occurred while executing that command.' ) ;
2022-11-15 09:06:18 -05:00
}
2023-02-13 02:37:23 -05:00
}
2022-11-15 09:06:18 -05:00
}
2023-02-13 02:37:23 -05:00
}
2023-03-05 05:04:10 -05:00
}