forked from engineering/cloudservices
Last attempt
parent
5076b7deef
commit
bb81cf6842
|
@ -5,6 +5,8 @@ import { Collection } from '.';
|
||||||
export default class Command {
|
export default class Command {
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
|
parentName: string
|
||||||
|
|
||||||
description?: string
|
description?: string
|
||||||
|
|
||||||
usage?: string
|
usage?: string
|
||||||
|
|
|
@ -55,7 +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 parentLabel = `${command}`;
|
||||||
let hasSubCommands = true;
|
let hasSubCommands = true;
|
||||||
while (hasSubCommands) {
|
while (hasSubCommands) {
|
||||||
if (!resolvedCommand.subcommands.size) {
|
if (!resolvedCommand.subcommands.size) {
|
||||||
|
@ -64,11 +64,11 @@ 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(); label += ` ${args[0]}`;
|
args.shift(); parentLabel += ` ${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(); label += ` ${args[0]}`; break;
|
resolvedCommand = subCmd; args.shift(); parentLabel += ` ${args[0]}`; break;
|
||||||
} else {
|
} else {
|
||||||
hasSubCommands = false; break;
|
hasSubCommands = false; break;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ export default class Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const finalCommand = resolvedCommand;
|
const finalCommand = resolvedCommand;
|
||||||
finalCommand.name = label;
|
finalCommand.parentName = parentLabel;
|
||||||
|
|
||||||
return Promise.resolve({ cmd: finalCommand, args });
|
return Promise.resolve({ cmd: finalCommand, args });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue