@@ -31,9 +31,7 @@ export class CommandHandler {
3131 logger ?: Logger ;
3232 } ) {
3333 if ( ! client )
34- throw new Error (
35- 'Property "client" is required when instantiating CommandHandler.'
36- ) ;
34+ throw new Error ( 'Property "client" is required when instantiating CommandHandler.' ) ;
3735
3836 this . _client = client ;
3937 this . _commandsPath = commandsPath ;
@@ -105,9 +103,7 @@ export class CommandHandler {
105103 for ( const validationFilePath of validationFilePaths ) {
106104 const validationFunc = require ( validationFilePath ) ;
107105 if ( typeof validationFunc !== 'function' ) {
108- throw new Error (
109- `Validation file ${ validationFilePath } must export a function by default.`
110- ) ;
106+ throw new Error ( `Validation file ${ validationFilePath } must export a function by default.` ) ;
111107 }
112108
113109 this . _validationFuncs . push ( validationFunc ) ;
@@ -118,21 +114,14 @@ export class CommandHandler {
118114 this . _client . on ( 'interactionCreate' , async ( interaction ) => {
119115 if ( ! interaction . isChatInputCommand ( ) ) return ;
120116
121- const command = this . _commands . find (
122- ( cmd ) => cmd . name === interaction . commandName
123- ) ;
117+ const command = this . _commands . find ( ( cmd ) => cmd . name === interaction . commandName ) ;
124118 if ( command ) {
125119 // Run validation functions
126120 if ( this . _validationFuncs . length ) {
127121 let canRun = true ;
128122
129123 for ( const validationFunc of this . _validationFuncs ) {
130- const cantRunCommand = await validationFunc (
131- interaction ,
132- command ,
133- this ,
134- this . _client
135- ) ;
124+ const cantRunCommand = await validationFunc ( interaction , command , this , this . _client ) ;
136125 if ( cantRunCommand ) {
137126 canRun = false ;
138127 break ;
@@ -153,8 +142,6 @@ export class CommandHandler {
153142 handler : this ,
154143 } ) ;
155144 }
156- } else {
157- interaction . reply ( { content : 'Command not found.' , ephemeral : true } ) ;
158145 }
159146 } ) ;
160147 }
0 commit comments