diff --git a/packages/koishi-core/src/command.ts b/packages/koishi-core/src/command.ts index f4e06fe0bb..d1942c1da6 100644 --- a/packages/koishi-core/src/command.ts +++ b/packages/koishi-core/src/command.ts @@ -206,7 +206,7 @@ export class Command { option (rawName: string, description: string, config?: OptionConfig): this option (rawName: string, ...args: [OptionConfig?] | [string, OptionConfig?]) { const description = typeof args[0] === 'string' ? args.shift() as string : undefined - const config = args[0] as CommandConfig || {} + const config = args[0] as OptionConfig || {} const option = parseOption(rawName, description, config, this._optsDef) this._options.push(option) for (const name of option.names) { diff --git a/packages/koishi-core/src/sender.ts b/packages/koishi-core/src/sender.ts index b607da8b24..d8960f0c59 100644 --- a/packages/koishi-core/src/sender.ts +++ b/packages/koishi-core/src/sender.ts @@ -21,10 +21,11 @@ import { } from './meta' export class SenderError extends Error { - constructor (args: Record, url: string, retcode: number) { + constructor (args: Record, url: string, retcode: number, selfId: number) { super(`Error when trying to send to ${url}, args: ${JSON.stringify(args)}, retcode: ${retcode}`) Object.defineProperties(this, { name: { value: 'SenderError' }, + selfId: { value: selfId }, code: { value: retcode }, args: { value: args }, url: { value: url }, @@ -77,9 +78,9 @@ export class Sender { if (retcode === 0 && !silent) { return camelCase(data) } else if (retcode < 0 && !silent) { - throw new SenderError(params, action, retcode) + throw new SenderError(params, action, retcode, this.app.selfId) } else if (retcode > 1) { - throw new SenderError(params, action, retcode) + throw new SenderError(params, action, retcode, this.app.selfId) } }