Commit d3771841 authored by nanahira's avatar nanahira

add type to CommandLocale

parent c5e8b4e0
...@@ -2,6 +2,7 @@ import { ...@@ -2,6 +2,7 @@ import {
BeforeEventName, BeforeEventName,
CommandConfigExtended, CommandConfigExtended,
CommandDefinitionFun, CommandDefinitionFun,
CommandLocaleDef,
CommandOptionConfigWithDescription, CommandOptionConfigWithDescription,
EventName, EventName,
KoishiCommandDefinition, KoishiCommandDefinition,
...@@ -113,7 +114,7 @@ export const CommandUse = <T extends Command, R extends any[]>( ...@@ -113,7 +114,7 @@ export const CommandUse = <T extends Command, R extends any[]>(
...args: R ...args: R
) => CommandDef((cmd) => callback(cmd, ...args)); ) => CommandDef((cmd) => callback(cmd, ...args));
export const CommandLocale = (locale: string, def: any) => export const CommandLocale = (locale: string, def: CommandLocaleDef) =>
CommandDef((cmd, ctx) => { CommandDef((cmd, ctx) => {
ctx.i18n.define(locale, `commands.${cmd.name}`, def); ctx.i18n.define(locale, `commands.${cmd.name}`, def);
return cmd; return cmd;
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
EventMap, EventMap,
Plugin, Plugin,
Selection, Selection,
Store,
} from 'koishi'; } from 'koishi';
import type { DefaultContext, DefaultState, ParameterizedContext } from 'koa'; import type { DefaultContext, DefaultState, ParameterizedContext } from 'koa';
import type { RouterParamContext } from '@koa/router'; import type { RouterParamContext } from '@koa/router';
...@@ -150,3 +151,9 @@ export type TopLevelActionDef = (ctx: Context, obj: any) => void; ...@@ -150,3 +151,9 @@ export type TopLevelActionDef = (ctx: Context, obj: any) => void;
export interface CommandOptionConfigWithDescription extends Argv.OptionConfig { export interface CommandOptionConfigWithDescription extends Argv.OptionConfig {
description?: string | Dict<string>; description?: string | Dict<string>;
} }
export interface CommandLocaleDef extends Store {
description?: string;
options?: Dict<string>;
messages?: Store;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment