forked from Galactic/galactic-bot
thing for command options
This commit is contained in:
parent
e0bc291fd9
commit
416cfb7a01
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user