-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Context } from 'koishi' | ||
import CommandManager from '.' | ||
|
||
export default function (ctx: Context, manager: CommandManager) { | ||
ctx.command('command <name>', '修改指令配置', { authority: 4 }) | ||
// .option('option', '-o [key] 修改指令选项') | ||
// .option('create', '-c 创建指令') | ||
// .option('force', '-f 当指令不存在时延迟修改') | ||
.option('alias', '-a [name] 添加指令别名') | ||
.option('unalias', '-A [name] 移除指令别名') | ||
.option('name', '-n [name] 修改指令显示名') | ||
.option('parent', '-p [name] 修改指令父级') | ||
.option('parent', '-P 移除指令父级', { value: '' }) | ||
.action(async ({ options }, name) => { | ||
const snapshot = manager.ensure(name) | ||
const command = snapshot.command | ||
if (options.alias) { | ||
const item = command._aliases[options.name] || {} | ||
const aliases = { ...command._aliases, [options.alias]: item } | ||
manager.alias(command, aliases, true) | ||
} | ||
if (options.unalias) { | ||
const aliases = { ...command._aliases } | ||
delete aliases[options.unalias] | ||
manager.alias(command, aliases, true) | ||
} | ||
if (options.name) { | ||
const item = command._aliases[options.name] || {} | ||
const aliases = { [options.name]: item, ...command._aliases } | ||
manager.alias(command, aliases, true) | ||
} | ||
if (typeof options.parent === 'string') { | ||
manager.teleport(command, options.parent, true) | ||
} | ||
return '已修改指令配置。' | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters