thing for command options

This commit is contained in:
Erik 2022-07-15 11:53:00 +03:00
parent e0bc291fd9
commit 416cfb7a01
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -54,18 +54,22 @@ class CommandOption {
// console.log(opt);
if (opt instanceof CommandOption) this.options.push(opt);
else if (opt.name instanceof Array) {
const { name: names, description, type, ...opts } = opt;
const { name: names, description, type, dependsOn, ...opts } = opt;
for (const name of names) {
// console.log(name);
const index = names.indexOf(name);
let desc = description,
_type = type;
_type = type,
_dependsOn = dependsOn;
if (description instanceof Array) desc = description[index] || 'Missing description';
if (type instanceof Array) {
_type = type[index];
if (!_type) throw new Error(`Missing type for option ${name} in command ${this.name}`);
}
this.options.push(new CommandOption({ name, type: _type, description: desc, ...opts }));
if (dependsOn instanceof Array) {
_dependsOn = dependsOn[index];
}
this.options.push(new CommandOption({ name, type: _type, description: desc, dependsOn: _dependsOn, ...opts }));
}
} else this.options.push(new CommandOption(opt));
}