@@ -231,18 +231,21 @@ export abstract class Command<T = Args, O extends CommandOptions = CommandOption
231
231
* @param options The command options given from the constructor.
232
232
*/
233
233
protected parseConstructorPreConditionsCooldown ( options : CommandOptions ) {
234
- const { cooldownLimit, cooldownDelay, cooldownScope, cooldownFilteredUsers } = options ;
235
234
const { defaultCooldown } = this . container . client . options ;
236
235
237
- if ( ( defaultCooldown && ! defaultCooldown . filteredCommands ?. includes ( this . name ) ) || ( cooldownLimit && cooldownDelay ) ) {
236
+ // We will check for whether the command is filtered from the defaults, but we will allow overridden values to
237
+ // be set. If an overridden value is passed, it will have priority. Otherwise it will default to 0 if filtered
238
+ // (causing the precondition to not be registered) or the default value with a fallback to a single-use cooldown.
239
+ const filtered = defaultCooldown ?. filteredCommands ?. includes ( this . name ) ?? false ;
240
+ const limit = options . cooldownLimit ?? ( filtered ? 0 : defaultCooldown ! . limit ?? 1 ) ;
241
+ const delay = options . cooldownDelay ?? ( filtered ? 0 : defaultCooldown ! . delay ?? 0 ) ;
242
+
243
+ if ( limit && delay ) {
244
+ const scope = options . cooldownScope ?? defaultCooldown ?. scope ?? BucketScope . User ;
245
+ const filteredUsers = options . cooldownFilteredUsers ?? defaultCooldown ?. filteredUsers ;
238
246
this . preconditions . append ( {
239
247
name : CommandPreConditions . Cooldown ,
240
- context : {
241
- scope : cooldownScope ?? defaultCooldown ?. scope ?? BucketScope . User ,
242
- limit : cooldownLimit ?? defaultCooldown ?. limit ?? 1 ,
243
- delay : cooldownDelay ?? defaultCooldown ?. delay ?? 0 ,
244
- filteredUsers : cooldownFilteredUsers ?? defaultCooldown ?. filteredUsers
245
- }
248
+ context : { scope, limit, delay, filteredUsers }
246
249
} ) ;
247
250
}
248
251
}
0 commit comments