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