Commit 3fcf14d2 authored by nanahira's avatar nanahira

adapt latest koishi

parent 79d85ae0
This diff is collapsed.
......@@ -69,6 +69,6 @@
"testEnvironment": "node"
},
"peerDependencies": {
"koishi": "^4.10.3"
"koishi": "^4.10.4"
}
}
......@@ -23,7 +23,6 @@ export const {
UseBeforeEvent,
UseMiddleware,
UsePreset,
UseFormatter,
UseInterval,
} = methodDecorators;
......@@ -64,10 +63,14 @@ export const CommandDescription = koishiRegistrar.decorateCommandTransformer(
export const CommandAlias = koishiRegistrar.decorateCommandTransformer(
(ctx, cmd, ...names: string[]) => cmd.alias(...names),
);
export const CommandShortcut = koishiRegistrar.decorateCommandTransformer(
(ctx, cmd, name: string | RegExp, config: Command.Shortcut = {}) =>
cmd.shortcut(name, config),
(ctx, cmd, pattern: string | RegExp, config: Command.Shortcut) =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
cmd.shortcut(pattern, config),
);
export const CommandUsage = koishiRegistrar.decorateCommandTransformer(
(ctx, cmd, text: Command.Usage) => cmd.usage(text),
);
......
......@@ -147,21 +147,12 @@ export class KoishiRegistrar extends SatoriRegistrar<Context> {
return command;
},
),
UseFormatter: this.decorateMethod(
'formatter',
({ ctx }, fun: I18n.Formatter, name: string) => {
ctx.i18n.formatter(name, fun);
ctx.on('dispose', () => {
delete ctx.i18n._formatters[name];
});
},
),
UsePreset: this.decorateMethod(
'preset',
({ ctx }, fun: I18n.Renderer, name: string) => {
ctx.i18n.preset(name, fun);
ctx.on('dispose', () => {
delete ctx.i18n._presets[fun.name];
delete ctx.i18n._presets[name];
});
},
),
......
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