Skip to content

Commit 76da7bb

Browse files
authored
fix: parse sub cmd (and groups) options properly (#835)
* fix: parse cub cmd (and groups) options properly * refactor: don't unnecessarily convert options * refactor: change around option check a little
1 parent 271665f commit 76da7bb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

interactions/client/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def __check_sub_group(_sub_group: Option):
668668
11, message="A sub command group cannot contain more than 25 sub commands!"
669669
)
670670
for _sub_command in _sub_group.options:
671-
__check_sub_command(Option(**_sub_command), _sub_group)
671+
__check_sub_command(_sub_command, _sub_group)
672672

673673
def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
674674
nonlocal _sub_cmds_present
@@ -704,7 +704,7 @@ def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
704704
)
705705
_sub_opt_names = []
706706
for _opt in _sub_command.options:
707-
__check_options(Option(**_opt), _sub_opt_names, _sub_command)
707+
__check_options(_opt, _sub_opt_names, _sub_command)
708708
del _sub_opt_names
709709

710710
def __check_options(_option: Option, _names: list, _sub_command: Option = MISSING):

interactions/client/models/command.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ class Option(DictSerializerMixin):
114114
def __attrs_post_init__(self):
115115
# needed for nested classes
116116
self.options = (
117-
[Option(**option) for option in self.options] if self.options is not None else None
117+
[Option(**option) if isinstance(option, dict) else option for option in self.options]
118+
if self.options is not None
119+
else None
118120
)
119121

120122

0 commit comments

Comments
 (0)