cool stuff
This commit is contained in:
parent
86fee37e62
commit
f629937b5a
@ -117,7 +117,8 @@ class CommandHandler extends Observer {
|
||||
const newOption = new CommandOption({
|
||||
name: matched.name, type: matched.type,
|
||||
minimum: matched.minimum, maximum: matched.maximum,
|
||||
_rawValue: option.value, dependsOn: matched.dependsOn
|
||||
_rawValue: option.value,
|
||||
dependsOn: matched.dependsOn, dependsOnMode: matched.dependsOnMode
|
||||
});
|
||||
const parsed = await this._parseOption(interaction, newOption);
|
||||
|
||||
@ -135,9 +136,14 @@ class CommandHandler extends Observer {
|
||||
|
||||
// Ensure option dependencies
|
||||
for (const opt of Object.values(options)) {
|
||||
for (const dep of opt.dependsOn) if (!options[dep]) {
|
||||
return { option: opt, error: true, dependency: dep };
|
||||
let hasDep = false;
|
||||
for (const dep of opt.dependsOn) {
|
||||
// AND logic
|
||||
if (!options[dep] && opt.dependsOnMode === 'AND') return { option: opt, error: true, dependency: dep };
|
||||
// OR logic
|
||||
if (options[dep]) hasDep = true;
|
||||
}
|
||||
if(!hasDep && opt.dependsOnMode === 'OR') return { option: opt, error: true, dependency: opt.dependsOn.join('** OR **') };
|
||||
}
|
||||
|
||||
if(error) return error;
|
||||
|
Loading…
Reference in New Issue
Block a user