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>();
5353/**
5454 * Registers a bootstrap hook that will be called when the CommandKit instance is created.
5555 * 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,
5757 * if you need access to the commandkit dependencies.
5858 * @param fn The bootstrap function to register.
5959 * @example ```ts
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import { Context } from '../commands/Context';
2424import { MessageCommandParser } from '../commands/MessageCommandParser' ;
2525import { CommandRegistrar } from '../register/CommandRegistrar' ;
2626import { Command , Middleware } from '../router' ;
27+ import { getConfig } from '../../config/config' ;
2728
2829/**
2930 * Function type for wrapping command execution with custom logic.
@@ -419,6 +420,12 @@ export class AppCommandHandler {
419420 source : Interaction | Message ,
420421 cmdName ?: string ,
421422 ) : Promise < PreparedAppCommandExecution | null > {
423+ const config = getConfig ( ) ;
424+
425+ if ( config . disablePrefixCommands && source instanceof Message ) {
426+ return null ;
427+ }
428+
422429 let parser : MessageCommandParser | undefined ;
423430
424431 // Extract command name (and possibly subcommand) from the source
@@ -429,6 +436,8 @@ export class AppCommandHandler {
429436 const prefix =
430437 await this . commandkit . config . getMessageCommandPrefix ( source ) ;
431438
439+ if ( ! prefix || ! prefix . length ) return null ;
440+
432441 parser = new MessageCommandParser (
433442 source ,
434443 Array . isArray ( prefix ) ? prefix : [ prefix ] ,
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ export function defineConfig(
5454 ...defaultConfig . typescript ,
5555 ...config . typescript ,
5656 } ,
57+ disablePrefixCommands :
58+ config . disablePrefixCommands ?? defaultConfig . disablePrefixCommands ,
5759 } ;
5860
5961 return defined ;
Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ export const defaultConfig: ResolvedCommandKitConfig = {
2424 production : true ,
2525 } ,
2626 typedCommands : true ,
27+ disablePrefixCommands : false ,
2728} ;
Original file line number Diff line number Diff line change @@ -66,4 +66,9 @@ export interface CommandKitConfig {
6666 * @default true
6767 */
6868 typedCommands ?: boolean ;
69+ /**
70+ * Whether or not to disable the prefix commands.
71+ * @default false
72+ */
73+ disablePrefixCommands ?: boolean ;
6974}
You can’t perform that action at this time.
0 commit comments