From f629937b5a5980b912549762c9e48262c9bfa7ba Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 11 Feb 2022 17:56:02 +0200 Subject: [PATCH] cool stuff --- src/structure/components/observers/CommandHandler.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index f908dcc..d6fb4a1 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -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;