From 8e80422cb09bbc3b11eb3e708b404163d26bf8e7 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Fri, 19 Feb 2021 04:54:49 -0600 Subject: [PATCH] fix(context): Fix options converting --- lib/context.js | 7 +++---- src/context.ts | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/context.js b/lib/context.js index cea426d5..2a525217 100644 --- a/lib/context.js +++ b/lib/context.js @@ -216,11 +216,10 @@ class CommandContext { const convertedOptions = {}; for (const option of options) { if (option.type === constants_1.CommandOptionType.SUB_COMMAND || option.type === constants_1.CommandOptionType.SUB_COMMAND_GROUP) { - if (option.options) - convertedOptions[option.name] = CommandContext.convertOptions(option.options); + convertedOptions[option.name] = option.options ? CommandContext.convertOptions(option.options) : {}; } - else if ('value' in option) - convertedOptions[option.name] = option.value !== undefined ? option.value : {}; + else + convertedOptions[option.name] = 'value' in option && option.value !== undefined ? option.value : {}; } return convertedOptions; } diff --git a/src/context.ts b/src/context.ts index 7ae47a31..0c500151 100644 --- a/src/context.ts +++ b/src/context.ts @@ -324,8 +324,8 @@ class CommandContext { const convertedOptions: { [key: string]: ConvertedOption } = {}; for (const option of options) { if (option.type === CommandOptionType.SUB_COMMAND || option.type === CommandOptionType.SUB_COMMAND_GROUP) { - if (option.options) convertedOptions[option.name] = CommandContext.convertOptions(option.options); - } else if ('value' in option) convertedOptions[option.name] = option.value !== undefined ? option.value : {}; + convertedOptions[option.name] = option.options ? CommandContext.convertOptions(option.options) : {}; + } else convertedOptions[option.name] = 'value' in option && option.value !== undefined ? option.value : {}; } return convertedOptions; }