@@ -31,9 +31,7 @@ export class CommandHandler {
31
31
logger ?: Logger ;
32
32
} ) {
33
33
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.' ) ;
37
35
38
36
this . _client = client ;
39
37
this . _commandsPath = commandsPath ;
@@ -105,9 +103,7 @@ export class CommandHandler {
105
103
for ( const validationFilePath of validationFilePaths ) {
106
104
const validationFunc = require ( validationFilePath ) ;
107
105
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.` ) ;
111
107
}
112
108
113
109
this . _validationFuncs . push ( validationFunc ) ;
@@ -118,21 +114,14 @@ export class CommandHandler {
118
114
this . _client . on ( 'interactionCreate' , async ( interaction ) => {
119
115
if ( ! interaction . isChatInputCommand ( ) ) return ;
120
116
121
- const command = this . _commands . find (
122
- ( cmd ) => cmd . name === interaction . commandName
123
- ) ;
117
+ const command = this . _commands . find ( ( cmd ) => cmd . name === interaction . commandName ) ;
124
118
if ( command ) {
125
119
// Run validation functions
126
120
if ( this . _validationFuncs . length ) {
127
121
let canRun = true ;
128
122
129
123
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 ) ;
136
125
if ( cantRunCommand ) {
137
126
canRun = false ;
138
127
break ;
@@ -153,8 +142,6 @@ export class CommandHandler {
153
142
handler : this ,
154
143
} ) ;
155
144
}
156
- } else {
157
- interaction . reply ( { content : 'Command not found.' , ephemeral : true } ) ;
158
145
}
159
146
} ) ;
160
147
}
0 commit comments