Skip to content

Commit

Permalink
fix(core): do not override command description by undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 2, 2020
1 parent 21197df commit f1c3605
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/koishi-core/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export interface CommandConfig {
description?: string
/** min authority */
authority?: number
authorityHint?: string
disable?: UserType<boolean>
maxUsage?: UserType<number>
maxUsageText?: string
Expand Down
3 changes: 2 additions & 1 deletion packages/koishi-core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export class Context {
command (rawName: string, description: string, config?: CommandConfig): Command
command (rawName: string, ...args: [CommandConfig?] | [string, CommandConfig?]) {
const description = typeof args[0] === 'string' ? args.shift() as string : undefined
const config = { description, ...args[0] as CommandConfig }
const config = args[0] as CommandConfig || {}
config.description = description ?? config.description
const [path] = rawName.split(' ', 1)
const declaration = rawName.slice(path.length)
const segments = path.toLowerCase().split(/(?=[\\./])/)
Expand Down

0 comments on commit f1c3605

Please sign in to comment.