Interface ContextOptions<TOptions>

Options for creating a new Context instance.

interface ContextOptions<TOptions> {
    client?: Client;
    commandsDir: string;
    commandString: string;
    hooks?: HooksEmitter<Hooks>;
    options?: TOptions;
    parseFn?: ParseCommandFn;
    plugins?: {
        description?: string;
        init: ((context: Context<OptionsConfig>) => MaybePromise<boolean>);
        meta?: Record<string, any>;
        name: string;
        version: string;
    }[];
    resolveFn?: ResolveCommandFn;
}

Type Parameters

Properties

client?: Client

The standard streams client

commandsDir: string

The path to the directory containing command modules

commandString: string

The command string to be executed

The hooks emitter

options?: TOptions

The options config for the command

parseFn?: ParseCommandFn

An optional function to replace the default command parser

plugins?: {
    description?: string;
    init: ((context: Context<OptionsConfig>) => MaybePromise<boolean>);
    meta?: Record<string, any>;
    name: string;
    version: string;
}[]

A list of plugins to load

Type declaration

  • Optionaldescription?: string
  • init: ((context: Context<OptionsConfig>) => MaybePromise<boolean>)

    Initialize the plugin.

      • (context): MaybePromise<boolean>
      • Parameters

        Returns MaybePromise<boolean>

        A boolean or promise that resolves to a boolean indicating whether the plugin was successfully initialized.

  • Optionalmeta?: Record<string, any>

    Additional metadata about the plugin that doesn't fit in the standard fields.

    Note: Plugin info on the Context object will be frozen after the plugin is initialized. However, the freeze is shallow, so the fields of this object will be mutable by default.

  • name: string
  • version: string
resolveFn?: ResolveCommandFn

An optional function to replace the default command resolver