1
0
Fork 0

Hopefully fix subcommand name issue in help

refactor/models
Bsian 2019-10-31 23:54:25 +00:00
parent 7e32cb50e2
commit 8d8156d22a
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 6 additions and 4 deletions

View File

@ -55,6 +55,7 @@ export default class Util {
} }
if (!resolvedCommand) return Promise.resolve({ cmd: null, args }); if (!resolvedCommand) return Promise.resolve({ cmd: null, args });
let label = `${command}`;
let hasSubCommands = true; let hasSubCommands = true;
while (hasSubCommands) { while (hasSubCommands) {
if (!resolvedCommand.subcommands.size) { if (!resolvedCommand.subcommands.size) {
@ -63,20 +64,21 @@ export default class Util {
hasSubCommands = false; break; hasSubCommands = false; break;
} else if (resolvedCommand.subcommands.has(args[0])) { } else if (resolvedCommand.subcommands.has(args[0])) {
resolvedCommand = resolvedCommand.subcommands.get(args[0]); resolvedCommand = resolvedCommand.subcommands.get(args[0]);
args.shift(); args.shift(); label += ` ${args[0]}`;
} else { } else {
for (const subCmd of resolvedCommand.subcommands.toArray()) { for (const subCmd of resolvedCommand.subcommands.toArray()) {
if (subCmd.aliases.includes(args[0])) { if (subCmd.aliases.includes(args[0])) {
resolvedCommand = subCmd; args.shift(); break; resolvedCommand = subCmd; args.shift(); label += ` ${args[0]}`; break;
} else { } else {
hasSubCommands = false; break; hasSubCommands = false; break;
} }
} }
break;
} }
} }
const finalCommand = resolvedCommand;
finalCommand.name = label;
return Promise.resolve({ cmd: resolvedCommand, args }); return Promise.resolve({ cmd: finalCommand, args });
} catch (error) { } catch (error) {
this.handleError(error, message); this.handleError(error, message);
return Promise.reject(error); return Promise.reject(error);