Skip to content

Commit

Permalink
fix(context): Fix options converting
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Feb 19, 2021
1 parent 7604605 commit 8e80422
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8e80422

Please sign in to comment.