File tree Expand file tree Collapse file tree 5 files changed +18
-1
lines changed Expand file tree Collapse file tree 5 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ const onApplicationBootstrapHooks = new Set<BootstrapFunction>();
53
53
/**
54
54
* Registers a bootstrap hook that will be called when the CommandKit instance is created.
55
55
* This is useful for plugins that need to run some code after the CommandKit instance is fully initialized.
56
- * Note that not all commandkit dependiencs are available at this point. It is recommended to use the `onApplicationBootstrap` hook instead,
56
+ * Note that not all commandkit dependencies are available at this point. It is recommended to use the `onApplicationBootstrap` hook instead,
57
57
* if you need access to the commandkit dependencies.
58
58
* @param fn The bootstrap function to register.
59
59
* @example ```ts
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import { Context } from '../commands/Context';
24
24
import { MessageCommandParser } from '../commands/MessageCommandParser' ;
25
25
import { CommandRegistrar } from '../register/CommandRegistrar' ;
26
26
import { Command , Middleware } from '../router' ;
27
+ import { getConfig } from '../../config/config' ;
27
28
28
29
/**
29
30
* Function type for wrapping command execution with custom logic.
@@ -419,6 +420,12 @@ export class AppCommandHandler {
419
420
source : Interaction | Message ,
420
421
cmdName ?: string ,
421
422
) : Promise < PreparedAppCommandExecution | null > {
423
+ const config = getConfig ( ) ;
424
+
425
+ if ( config . disablePrefixCommands && source instanceof Message ) {
426
+ return null ;
427
+ }
428
+
422
429
let parser : MessageCommandParser | undefined ;
423
430
424
431
// Extract command name (and possibly subcommand) from the source
@@ -429,6 +436,8 @@ export class AppCommandHandler {
429
436
const prefix =
430
437
await this . commandkit . config . getMessageCommandPrefix ( source ) ;
431
438
439
+ if ( ! prefix || ! prefix . length ) return null ;
440
+
432
441
parser = new MessageCommandParser (
433
442
source ,
434
443
Array . isArray ( prefix ) ? prefix : [ prefix ] ,
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ export function defineConfig(
54
54
...defaultConfig . typescript ,
55
55
...config . typescript ,
56
56
} ,
57
+ disablePrefixCommands :
58
+ config . disablePrefixCommands ?? defaultConfig . disablePrefixCommands ,
57
59
} ;
58
60
59
61
return defined ;
Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ export const defaultConfig: ResolvedCommandKitConfig = {
24
24
production : true ,
25
25
} ,
26
26
typedCommands : true ,
27
+ disablePrefixCommands : false ,
27
28
} ;
Original file line number Diff line number Diff line change @@ -66,4 +66,9 @@ export interface CommandKitConfig {
66
66
* @default true
67
67
*/
68
68
typedCommands ?: boolean ;
69
+ /**
70
+ * Whether or not to disable the prefix commands.
71
+ * @default false
72
+ */
73
+ disablePrefixCommands ?: boolean ;
69
74
}
You can’t perform that action at this time.
0 commit comments