Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parse sub cmd (and groups) options properly #835

Merged
merged 3 commits into from Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions interactions/client/bot.py
Expand Up @@ -668,7 +668,7 @@ def __check_sub_group(_sub_group: Option):
11, message="A sub command group cannot contain more than 25 sub commands!"
)
for _sub_command in _sub_group.options:
__check_sub_command(Option(**_sub_command), _sub_group)
EdVraz marked this conversation as resolved.
Show resolved Hide resolved
__check_sub_command(_sub_command, _sub_group)

def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
nonlocal _sub_cmds_present
Expand Down Expand Up @@ -704,7 +704,7 @@ def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
)
_sub_opt_names = []
for _opt in _sub_command.options:
__check_options(Option(**_opt), _sub_opt_names, _sub_command)
__check_options(_opt, _sub_opt_names, _sub_command)
del _sub_opt_names

def __check_options(_option: Option, _names: list, _sub_command: Option = MISSING):
Expand Down
4 changes: 3 additions & 1 deletion interactions/client/models/command.py
Expand Up @@ -114,7 +114,9 @@ class Option(DictSerializerMixin):
def __attrs_post_init__(self):
# needed for nested classes
self.options = (
[Option(**option) for option in self.options] if self.options is not None else None
[Option(**option) if isinstance(option, dict) else option for option in self.options]
if self.options is not None
else None
)


Expand Down