diff --git a/packages/api/src/command.ts b/packages/api/src/command.ts index eafb1c9e..5e652d6b 100644 --- a/packages/api/src/command.ts +++ b/packages/api/src/command.ts @@ -13,7 +13,7 @@ export namespace command { */ on(plugin: plugin.Plugin, name: string, exec: { cmd: Function, tab?: Function }) { var cmd = this.create(plugin, name) - if (!cmd) { throw Error("") } + if (!cmd) { throw Error(`Plugin ${plugin.description.name} can't create Command ${name}!`) } console.debug(i18n.translate("ms.api.command.register", { plugin: plugin.description.name, name, cmd })) if (exec.cmd && typeof exec.cmd === "function") { this.onCommand(plugin, cmd, exec.cmd) diff --git a/packages/plugin/src/command.ts b/packages/plugin/src/command.ts index c957e26e..227f00f8 100644 --- a/packages/plugin/src/command.ts +++ b/packages/plugin/src/command.ts @@ -18,17 +18,17 @@ export class PluginCommandManager { let cmds = getPluginCommandMetadata(pluginInstance) let tabs = getPluginTabCompleterMetadata(pluginInstance) for (const cmd of cmds) { - let tab = tabs.get(cmd.name) if (!this.ServerChecker.check(cmd.servers)) { console.debug(`[${pluginInstance.description.name}] ${cmd.target.constructor.name} incompatible command ${cmd.name} server(${cmd.servers}) ignore.`) continue } - let exec = { - cmd: pluginInstance[cmd.executor].bind(pluginInstance), - tab: tab ? pluginInstance[tab.executor].bind(pluginInstance) : undefined - } for (let command of [cmd.name, ...cmd.alias]) { - this.CommandManager.on(pluginInstance, command, exec) + this.CommandManager.on(pluginInstance, command, { + cmd: pluginInstance[cmd.executor].bind(pluginInstance), + tab: tabs.has(command) ? + pluginInstance[tabs.get(command).executor].bind(pluginInstance) : + console.debug(`[${pluginInstance.description.name}] command ${cmd.name} is not registry tabCompleter`) + }) } } }