@koishijs/core
Advanced tools
Comparing version 4.16.4 to 4.16.5
@@ -309,7 +309,9 @@ import * as utils from '@koishijs/utils'; | ||
date: Date; | ||
image: { | ||
src?: string; | ||
}; | ||
img: JSX.IntrinsicElements['img']; | ||
image: JSX.IntrinsicElements['img']; | ||
audio: JSX.IntrinsicElements['audio']; | ||
video: JSX.IntrinsicElements['video']; | ||
file: JSX.IntrinsicElements['file']; | ||
} | ||
type DomainType = keyof Domain; | ||
export type DomainType = keyof Domain; | ||
type ParamType<S extends string, F> = S extends `${any}:${infer T}` ? T extends DomainType ? Domain[T] : F : F; | ||
@@ -331,3 +333,3 @@ type Replace<S extends string, X extends string, Y extends string> = S extends `${infer L}${X}${infer R}` ? `${L}${Y}${Replace<R, X, Y>}` : S; | ||
export type Transform<T> = (source: string, session: Session) => T; | ||
export interface DomainConfig<T> { | ||
export interface DomainConfig<T = any> { | ||
transform?: Transform<T>; | ||
@@ -337,4 +339,2 @@ greedy?: boolean; | ||
} | ||
export function createDomain<K extends keyof Domain>(name: K, transform: Transform<Domain[K]>, options?: DomainConfig<Domain[K]>): void; | ||
export function parseValue(source: string, kind: string, argv: Argv, decl?: Declaration): any; | ||
export interface OptionConfig<T extends Type = Type> extends Permissions.Config { | ||
@@ -373,3 +373,3 @@ aliases?: string[]; | ||
_options: OptionDeclarationMap; | ||
_disposables?: Disposable[]; | ||
_disposables: Disposable[]; | ||
private _namedOptions; | ||
@@ -416,8 +416,2 @@ private _symbolicOptions; | ||
private _checkers; | ||
private static _userFields; | ||
private static _channelFields; | ||
/** @deprecated use `command-added` event instead */ | ||
static userFields(fields: FieldCollector<'user'>): typeof Command; | ||
/** @deprecated use `command-added` event instead */ | ||
static channelFields(fields: FieldCollector<'channel'>): typeof Command; | ||
constructor(name: string, decl: string, ctx: Context, config: Command.Config); | ||
@@ -435,5 +429,7 @@ get caller(): Context; | ||
_escape(source: any): any; | ||
/** @deprecated please use `cmd.alias()` instead */ | ||
shortcut(pattern: string | RegExp, config?: Command.Shortcut & { | ||
i18n?: false; | ||
}): this; | ||
/** @deprecated please use `cmd.alias()` instead */ | ||
shortcut(pattern: string, config: Command.Shortcut & { | ||
@@ -483,2 +479,3 @@ i18n: true; | ||
'command-added'(command: Command): void; | ||
'command-updated'(command: Command): void; | ||
'command-removed'(command: Command): void; | ||
@@ -490,2 +487,5 @@ 'command-error'(argv: Argv, error: any): void; | ||
} | ||
export interface DeclarationList extends Array<Argv.Declaration> { | ||
stripped: string; | ||
} | ||
export namespace Commander { | ||
@@ -496,8 +496,9 @@ interface Config { | ||
} | ||
export class Commander extends Map<string, Command> { | ||
export class Commander { | ||
private ctx; | ||
private config; | ||
_commandList: Command[]; | ||
_commands: this; | ||
constructor(ctx: Context, config?: Commander.Config); | ||
private defineElementDomain; | ||
get(name: string, strict?: boolean): Command<never, never, any[], {}>; | ||
updateCommands(bot: Bot): Promise<void>; | ||
@@ -517,2 +518,7 @@ private _resolvePrefixes; | ||
command(def: string, ...args: [Command.Config?] | [string, Command.Config?]): Command<never, never, any[], {}>; | ||
domain<K extends keyof Argv.Domain>(name: K): Argv.DomainConfig<Argv.Domain[K]>; | ||
domain<K extends keyof Argv.Domain>(name: K, transform: Argv.Transform<Argv.Domain[K]>, options?: Argv.DomainConfig<Argv.Domain[K]>): void; | ||
resolveDomain(type: Argv.Type): any; | ||
parseValue(source: string, kind: string, argv: Argv, decl?: Argv.Declaration): any; | ||
parseDecl(source: string): DeclarationList; | ||
} | ||
@@ -519,0 +525,0 @@ export interface PromptOptions { |
{ | ||
"name": "@koishijs/core", | ||
"description": "Core Features for Koishi", | ||
"version": "4.16.4", | ||
"version": "4.16.5", | ||
"main": "lib/index.cjs", | ||
@@ -37,4 +37,4 @@ "module": "lib/index.mjs", | ||
"@minatojs/core": "^2.8.1", | ||
"@satorijs/core": "^3.4.1", | ||
"cordis": "^3.6.0", | ||
"@satorijs/core": "^3.4.2", | ||
"cordis": "^3.6.1", | ||
"cosmokit": "^1.5.2", | ||
@@ -41,0 +41,0 @@ "fastest-levenshtein": "^1.0.16" |
@@ -49,3 +49,3 @@ import { Awaitable, camelize, Dict, isNullable, remove } from 'cosmokit' | ||
_parent: Command = null | ||
_aliases: Dict<Command.Alias> = {} | ||
_aliases: Dict<Command.Alias> = Object.create(null) | ||
_examples: string[] = [] | ||
@@ -61,17 +61,2 @@ _usage?: Command.Usage | ||
private static _userFields: FieldCollector<'user'>[] = [] | ||
private static _channelFields: FieldCollector<'channel'>[] = [] | ||
/** @deprecated use `command-added` event instead */ | ||
static userFields(fields: FieldCollector<'user'>) { | ||
this._userFields.push(fields) | ||
return this | ||
} | ||
/** @deprecated use `command-added` event instead */ | ||
static channelFields(fields: FieldCollector<'channel'>) { | ||
this._channelFields.push(fields) | ||
return this | ||
} | ||
constructor(name: string, decl: string, ctx: Context, config: Command.Config) { | ||
@@ -120,2 +105,8 @@ super(name, decl, ctx, { | ||
// check global | ||
const previous = this.ctx.$commander.get(name) | ||
if (previous && previous !== this) { | ||
throw new Error(`duplicate command names: "${name}"`) | ||
} | ||
// add to list | ||
@@ -127,3 +118,2 @@ const existing = this._aliases[name] | ||
} | ||
return | ||
} else if (prepend) { | ||
@@ -134,10 +124,2 @@ this._aliases = { [name]: options, ...this._aliases } | ||
} | ||
// register global | ||
const previous = this.ctx.$commander.get(name) | ||
if (!previous) { | ||
this.ctx.$commander.set(name, this) | ||
} else if (previous !== this) { | ||
throw new Error(`duplicate command names: "${name}"`) | ||
} | ||
} | ||
@@ -169,2 +151,3 @@ | ||
} | ||
this.caller.emit('command-updated', this) | ||
return this | ||
@@ -181,3 +164,5 @@ } | ||
/** @deprecated please use `cmd.alias()` instead */ | ||
shortcut(pattern: string | RegExp, config?: Command.Shortcut & { i18n?: false }): this | ||
/** @deprecated please use `cmd.alias()` instead */ | ||
shortcut(pattern: string, config: Command.Shortcut & { i18n: true }): this | ||
@@ -249,2 +234,3 @@ shortcut(pattern: string | RegExp, config: Command.Shortcut = {}) { | ||
this._createOption(name, desc, config) | ||
this.caller.emit('command-updated', this) | ||
this.caller.collect('option', () => this.removeOption(name)) | ||
@@ -350,5 +336,2 @@ return this | ||
} | ||
for (const name in this._aliases) { | ||
this.ctx.$commander.delete(name) | ||
} | ||
remove(this.ctx.$commander._commandList, this) | ||
@@ -355,0 +338,0 @@ this.parent = null |
@@ -1,2 +0,2 @@ | ||
import { Awaitable, defineProperty } from 'cosmokit' | ||
import { Awaitable, defineProperty, Time } from 'cosmokit' | ||
import { Bot, h, Schema, Universal } from '@satorijs/core' | ||
@@ -25,2 +25,3 @@ import { Command } from './command' | ||
'command-added'(command: Command): void | ||
'command-updated'(command: Command): void | ||
'command-removed'(command: Command): void | ||
@@ -34,2 +35,12 @@ 'command-error'(argv: Argv, error: any): void | ||
// https://github.com/microsoft/TypeScript/issues/17002 | ||
// it never got fixed so we have to do this | ||
const isArray = Array.isArray as (arg: any) => arg is readonly any[] | ||
const BRACKET_REGEXP = /<[^>]+>|\[[^\]]+\]/g | ||
interface DeclarationList extends Array<Argv.Declaration> { | ||
stripped: string | ||
} | ||
export namespace Commander { | ||
@@ -41,8 +52,6 @@ export interface Config { | ||
export class Commander extends Map<string, Command> { | ||
export class Commander { | ||
_commandList: Command[] = [] | ||
_commands = this | ||
constructor(private ctx: Context, private config: Commander.Config = {}) { | ||
super() | ||
defineProperty(this, Context.current, ctx) | ||
@@ -152,4 +161,87 @@ ctx.plugin(validate) | ||
}) | ||
this.domain('el', source => h.parse(source), { greedy: true }) | ||
this.domain('elements', source => h.parse(source), { greedy: true }) | ||
this.domain('string', source => h.unescape(source)) | ||
this.domain('text', source => h.unescape(source), { greedy: true }) | ||
this.domain('rawtext', source => h('', h.parse(source)).toString(true), { greedy: true }) | ||
this.domain('boolean', () => true) | ||
this.domain('number', (source, session) => { | ||
const value = +source | ||
if (Number.isFinite(value)) return value | ||
throw new Error('internal.invalid-number') | ||
}, { numeric: true }) | ||
this.domain('integer', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value) return value | ||
throw new Error('internal.invalid-integer') | ||
}, { numeric: true }) | ||
this.domain('posint', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value && value > 0) return value | ||
throw new Error('internal.invalid-posint') | ||
}, { numeric: true }) | ||
this.domain('natural', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value && value >= 0) return value | ||
throw new Error('internal.invalid-natural') | ||
}, { numeric: true }) | ||
this.domain('date', (source, session) => { | ||
const timestamp = Time.parseDate(source) | ||
if (+timestamp) return timestamp | ||
throw new Error('internal.invalid-date') | ||
}) | ||
this.domain('user', (source, session) => { | ||
if (source.startsWith('@')) { | ||
source = source.slice(1) | ||
if (source.includes(':')) return source | ||
return `${session.platform}:${source}` | ||
} | ||
const code = h.from(source) | ||
if (code && code.type === 'at') { | ||
return `${session.platform}:${code.attrs.id}` | ||
} | ||
throw new Error('internal.invalid-user') | ||
}) | ||
this.domain('channel', (source, session) => { | ||
if (source.startsWith('#')) { | ||
source = source.slice(1) | ||
if (source.includes(':')) return source | ||
return `${session.platform}:${source}` | ||
} | ||
const code = h.from(source) | ||
if (code && code.type === 'sharp') { | ||
return `${session.platform}:${code.attrs.id}` | ||
} | ||
throw new Error('internal.invalid-channel') | ||
}) | ||
this.defineElementDomain('image', 'image', 'img') | ||
this.defineElementDomain('img', 'image', 'img') | ||
this.defineElementDomain('audio') | ||
this.defineElementDomain('video') | ||
this.defineElementDomain('file') | ||
} | ||
private defineElementDomain(name: keyof Argv.Domain, key = name, type = name) { | ||
this.domain(name, (source, session) => { | ||
const code = h.from(source) | ||
if (code && code.type === type) { | ||
return code.attrs | ||
} | ||
throw new Error(`internal.invalid-${key}`) | ||
}) | ||
} | ||
get(name: string, strict?: boolean) { | ||
return this._commandList.find(cmd => strict ? cmd.name === name : cmd._aliases[name]) | ||
} | ||
updateCommands(bot: Bot) { | ||
@@ -268,2 +360,3 @@ return bot.updateCommands(this._commandList | ||
Object.assign(parent.config, config) | ||
// Make sure `command.config` is set before emitting any events | ||
created.forEach(command => caller.emit('command-added', command)) | ||
@@ -274,2 +367,80 @@ parent[Context.current] = caller | ||
} | ||
domain<K extends keyof Argv.Domain>(name: K): Argv.DomainConfig<Argv.Domain[K]> | ||
domain<K extends keyof Argv.Domain>(name: K, transform: Argv.Transform<Argv.Domain[K]>, options?: Argv.DomainConfig<Argv.Domain[K]>): void | ||
domain<K extends keyof Argv.Domain>(name: K, transform?: Argv.Transform<Argv.Domain[K]>, options?: Argv.DomainConfig<Argv.Domain[K]>) { | ||
const caller = this[Context.current] as Context | ||
const service = 'domain:' + name | ||
if (!transform) return caller.get(service) | ||
this.ctx.provide(service) | ||
return caller.effect(() => { | ||
caller[service] = { transform, ...options } | ||
return () => caller[service] = null | ||
}) | ||
} | ||
resolveDomain(type: Argv.Type) { | ||
if (typeof type === 'function') { | ||
return { transform: type } | ||
} else if (type instanceof RegExp) { | ||
const transform = (source: string) => { | ||
if (type.test(source)) return source | ||
throw new Error() | ||
} | ||
return { transform } | ||
} else if (isArray(type)) { | ||
const transform = (source: string) => { | ||
if (type.includes(source)) return source | ||
throw new Error() | ||
} | ||
return { transform } | ||
} else if (typeof type === 'object') { | ||
return type ?? {} | ||
} | ||
return this.ctx.get(`domain:${type}`) ?? {} | ||
} | ||
parseValue(source: string, kind: string, argv: Argv, decl: Argv.Declaration = {}) { | ||
const { name, type = 'string' } = decl | ||
// apply domain callback | ||
const domain = this.resolveDomain(type) | ||
try { | ||
return domain.transform(source, argv.session) | ||
} catch (err) { | ||
if (!argv.session) { | ||
argv.error = `internal.invalid-${kind}` | ||
} else { | ||
const message = argv.session.text(err['message'] || 'internal.check-syntax') | ||
argv.error = argv.session.text(`internal.invalid-${kind}`, [name, message]) | ||
} | ||
} | ||
} | ||
parseDecl(source: string) { | ||
let cap: RegExpExecArray | ||
const result = [] as DeclarationList | ||
// eslint-disable-next-line no-cond-assign | ||
while (cap = BRACKET_REGEXP.exec(source)) { | ||
let rawName = cap[0].slice(1, -1) | ||
let variadic = false | ||
if (rawName.startsWith('...')) { | ||
rawName = rawName.slice(3) | ||
variadic = true | ||
} | ||
const [name, rawType] = rawName.split(':') | ||
const type = rawType ? rawType.trim() as Argv.DomainType : undefined | ||
result.push({ | ||
name, | ||
variadic, | ||
type, | ||
required: cap[0][0] === '<', | ||
}) | ||
} | ||
result.stripped = source.replace(/:[\w-]+(?=[>\]])/g, str => { | ||
const domain = this.ctx.get(`domain:${str.slice(1)}`) | ||
return domain?.greedy ? '...' : '' | ||
}).trimEnd() | ||
return result | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { camelCase, Dict, paramCase, Time } from 'cosmokit' | ||
import { camelCase, Dict, paramCase } from 'cosmokit' | ||
import { escapeRegExp } from '@koishijs/utils' | ||
@@ -186,8 +186,10 @@ import { h } from '@satorijs/core' | ||
date: Date | ||
image: { | ||
src?: string | ||
} | ||
img: JSX.IntrinsicElements['img'] | ||
image: JSX.IntrinsicElements['img'] | ||
audio: JSX.IntrinsicElements['audio'] | ||
video: JSX.IntrinsicElements['video'] | ||
file: JSX.IntrinsicElements['file'] | ||
} | ||
type DomainType = keyof Domain | ||
export type DomainType = keyof Domain | ||
@@ -226,3 +228,3 @@ type ParamType<S extends string, F> | ||
export interface DomainConfig<T> { | ||
export interface DomainConfig<T = any> { | ||
transform?: Transform<T> | ||
@@ -233,154 +235,2 @@ greedy?: boolean | ||
// https://github.com/microsoft/TypeScript/issues/17002 | ||
// it never got fixed so we have to do this | ||
const isArray = Array.isArray as (arg: any) => arg is readonly any[] | ||
function resolveDomain(type: Type) { | ||
if (typeof type === 'function') { | ||
return { transform: type } | ||
} else if (type instanceof RegExp) { | ||
const transform = (source: string) => { | ||
if (type.test(source)) return source | ||
throw new Error() | ||
} | ||
return { transform } | ||
} else if (isArray(type)) { | ||
const transform = (source: string) => { | ||
if (type.includes(source)) return source | ||
throw new Error() | ||
} | ||
return { transform } | ||
} else if (typeof type === 'object') { | ||
return type ?? {} | ||
} | ||
return builtin[type] ?? {} | ||
} | ||
const builtin: Dict<DomainConfig<any>> = {} | ||
export function createDomain<K extends keyof Domain>(name: K, transform: Transform<Domain[K]>, options?: DomainConfig<Domain[K]>) { | ||
builtin[name] = { ...options, transform } | ||
} | ||
createDomain('el', source => h.parse(source), { greedy: true }) | ||
createDomain('elements', source => h.parse(source), { greedy: true }) | ||
createDomain('string', source => h.unescape(source)) | ||
createDomain('text', source => h.unescape(source), { greedy: true }) | ||
createDomain('rawtext', source => h('', h.parse(source)).toString(true), { greedy: true }) | ||
createDomain('boolean', () => true) | ||
createDomain('number', (source, session) => { | ||
const value = +source | ||
if (Number.isFinite(value)) return value | ||
throw new Error('internal.invalid-number') | ||
}, { numeric: true }) | ||
createDomain('integer', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value) return value | ||
throw new Error('internal.invalid-integer') | ||
}, { numeric: true }) | ||
createDomain('posint', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value && value > 0) return value | ||
throw new Error('internal.invalid-posint') | ||
}, { numeric: true }) | ||
createDomain('natural', (source, session) => { | ||
const value = +source | ||
if (value * 0 === 0 && Math.floor(value) === value && value >= 0) return value | ||
throw new Error('internal.invalid-natural') | ||
}, { numeric: true }) | ||
createDomain('date', (source, session) => { | ||
const timestamp = Time.parseDate(source) | ||
if (+timestamp) return timestamp | ||
throw new Error('internal.invalid-date') | ||
}) | ||
createDomain('user', (source, session) => { | ||
if (source.startsWith('@')) { | ||
source = source.slice(1) | ||
if (source.includes(':')) return source | ||
return `${session.platform}:${source}` | ||
} | ||
const code = h.from(source) | ||
if (code && code.type === 'at') { | ||
return `${session.platform}:${code.attrs.id}` | ||
} | ||
throw new Error('internal.invalid-user') | ||
}) | ||
createDomain('channel', (source, session) => { | ||
if (source.startsWith('#')) { | ||
source = source.slice(1) | ||
if (source.includes(':')) return source | ||
return `${session.platform}:${source}` | ||
} | ||
const code = h.from(source) | ||
if (code && code.type === 'sharp') { | ||
return `${session.platform}:${code.attrs.id}` | ||
} | ||
throw new Error('internal.invalid-channel') | ||
}) | ||
createDomain('image', (source, session) => { | ||
const code = h.from(source) | ||
if (code && code.type === 'img') { | ||
return code.attrs | ||
} | ||
throw new Error('internal.invalid-image') | ||
}) | ||
const BRACKET_REGEXP = /<[^>]+>|\[[^\]]+\]/g | ||
interface DeclarationList extends Array<Declaration> { | ||
stripped: string | ||
} | ||
function parseDecl(source: string) { | ||
let cap: RegExpExecArray | ||
const result = [] as DeclarationList | ||
// eslint-disable-next-line no-cond-assign | ||
while (cap = BRACKET_REGEXP.exec(source)) { | ||
let rawName = cap[0].slice(1, -1) | ||
let variadic = false | ||
if (rawName.startsWith('...')) { | ||
rawName = rawName.slice(3) | ||
variadic = true | ||
} | ||
const [name, rawType] = rawName.split(':') | ||
const type = rawType ? rawType.trim() as DomainType : undefined | ||
result.push({ | ||
name, | ||
variadic, | ||
type, | ||
required: cap[0][0] === '<', | ||
}) | ||
} | ||
result.stripped = source.replace(/:[\w-]+(?=[>\]])/g, str => { | ||
const domain = builtin[str.slice(1)] | ||
return domain?.greedy ? '...' : '' | ||
}).trimEnd() | ||
return result | ||
} | ||
export function parseValue(source: string, kind: string, argv: Argv, decl: Declaration = {}) { | ||
const { name, type = 'string' } = decl | ||
// apply domain callback | ||
const domain = resolveDomain(type) | ||
try { | ||
return domain.transform(source, argv.session) | ||
} catch (err) { | ||
if (!argv.session) { | ||
argv.error = `internal.invalid-${kind}` | ||
} else { | ||
const message = argv.session.text(err['message'] || 'internal.check-syntax') | ||
argv.error = argv.session.text(`internal.invalid-${kind}`, [name, message]) | ||
} | ||
} | ||
} | ||
export interface OptionConfig<T extends Type = Type> extends Permissions.Config { | ||
@@ -423,3 +273,3 @@ aliases?: string[] | ||
public _options: OptionDeclarationMap = {} | ||
public _disposables?: Disposable[] = [] | ||
public _disposables: Disposable[] = [] | ||
@@ -431,3 +281,3 @@ private _namedOptions: OptionDeclarationMap = {} | ||
if (!name) throw new Error('expect a command name') | ||
const declList = this._arguments = parseDecl(declaration) | ||
const declList = this._arguments = ctx.$commander.parseDecl(declaration) | ||
this.declaration = declList.stripped | ||
@@ -463,3 +313,3 @@ for (const decl of declList) { | ||
const declList = parseDecl(bracket.trimStart()) | ||
const declList = this.ctx.$commander.parseDecl(bracket.trimStart()) | ||
if (declList.stripped) syntax += ' ' + declList.stripped | ||
@@ -543,4 +393,4 @@ const option = this._options[name] ||= { | ||
// greedy argument | ||
if (content[0] !== '-' && resolveDomain(argDecl.type).greedy) { | ||
args.push(Argv.parseValue(Argv.stringify(argv), 'argument', argv, argDecl)) | ||
if (content[0] !== '-' && this.ctx.$commander.resolveDomain(argDecl.type).greedy) { | ||
args.push(this.ctx.$commander.parseValue(Argv.stringify(argv), 'argument', argv, argDecl)) | ||
break | ||
@@ -559,4 +409,4 @@ } | ||
// normal argument | ||
if (content[0] !== '-' || quoted || (+content) * 0 === 0 && resolveDomain(argDecl.type).numeric) { | ||
args.push(Argv.parseValue(content, 'argument', argv, argDecl)) | ||
if (content[0] !== '-' || quoted || (+content) * 0 === 0 && this.ctx.$commander.resolveDomain(argDecl.type).numeric) { | ||
args.push(this.ctx.$commander.parseValue(content, 'argument', argv, argDecl)) | ||
continue | ||
@@ -578,3 +428,3 @@ } | ||
if (this.config.strictOptions && !this._namedOptions[name]) { | ||
args.push(Argv.parseValue(content, 'argument', argv, argDecl)) | ||
args.push(this.ctx.$commander.parseValue(content, 'argument', argv, argDecl)) | ||
continue | ||
@@ -595,3 +445,3 @@ } | ||
const { type, values } = option || {} | ||
if (resolveDomain(type).greedy) { | ||
if (this.ctx.$commander.resolveDomain(type).greedy) { | ||
param = Argv.stringify(argv) | ||
@@ -620,3 +470,3 @@ quoted = true | ||
const source = j + 1 < names.length ? '' : param | ||
options[key] = Argv.parseValue(source, 'option', argv, optDecl) | ||
options[key] = this.ctx.$commander.parseValue(source, 'option', argv, optDecl) | ||
} | ||
@@ -623,0 +473,0 @@ if (argv.error) break |
@@ -76,3 +76,3 @@ import { isNullable } from 'cosmokit' | ||
} | ||
args.push(Argv.parseValue(source, 'argument', argv, decl)) | ||
args.push(ctx.$commander.parseValue(source, 'argument', argv, decl)) | ||
index++ | ||
@@ -79,0 +79,0 @@ } |
@@ -6,3 +6,3 @@ import { observe } from '@koishijs/utils' | ||
import * as satori from '@satorijs/core' | ||
import { Argv, Command } from './command' | ||
import { Argv } from './command' | ||
import { Context } from './context' | ||
@@ -344,3 +344,2 @@ import { Channel, Tables, User } from './database' | ||
this.app.emit(argv.session, `command/before-attach-${key}` as any, argv, fields) | ||
collectFields(argv, Command[`_${key}Fields` as any], fields) | ||
collectFields(argv, argv.command[`_${key}Fields` as any], fields) | ||
@@ -347,0 +346,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
471212
8819
Updated@satorijs/core@^3.4.2
Updatedcordis@^3.6.1