Skip to content

Commit 66d1df5

Browse files
authored
Fix!: prevent NoneType error during sub command checks and add kwarg for sub_commands without options (#568)
* fix!: make context not required * fix!: remove requirement of reason in helper methods * Update gateway.py * Update client.py * fix!: remove requirement of reason in helper methods * fix!: add _client to Attachement class
1 parent c2b658d commit 66d1df5

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

interactions/api/gateway.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ def _check_auto(option: dict) -> Optional[Tuple[str]]:
489489
return _check
490490

491491
__kwargs[sub_option["name"]] = sub_option["value"]
492+
493+
elif _data.get("type") and _data["type"] == OptionType.SUB_COMMAND:
494+
# sub_command_groups must have options so there is no extra check needed for those
495+
__kwargs["sub_command"] = _data["name"]
496+
492497
elif _data.get("value") and _data.get("name"):
493498
__kwargs[_data["name"]] = _data["value"]
494499

interactions/api/models/message.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class Attachment(DictSerializerMixin):
105105
"""
106106

107107
__slots__ = (
108+
"_client",
108109
"_json",
109110
"id",
110111
"filename",

interactions/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
399399
raise InteractionException(
400400
11, message="Descriptions must be less than 100 characters."
401401
)
402-
if _sub_command.options is not MISSING:
402+
if _sub_command.options is not MISSING and _sub_command.options:
403403
if len(_sub_command.options) > 25:
404404
raise InteractionException(
405405
11, message="Your sub command must have less than 25 options."

0 commit comments

Comments
 (0)