Skip to content

Commit

Permalink
Fix!: prevent NoneType error during sub command checks and add kw…
Browse files Browse the repository at this point in the history
…arg 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
  • Loading branch information
EdVraz committed Feb 26, 2022
1 parent c2b658d commit 66d1df5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions interactions/api/gateway.py
Expand Up @@ -489,6 +489,11 @@ def _check_auto(option: dict) -> Optional[Tuple[str]]:
return _check

__kwargs[sub_option["name"]] = sub_option["value"]

elif _data.get("type") and _data["type"] == OptionType.SUB_COMMAND:
# sub_command_groups must have options so there is no extra check needed for those
__kwargs["sub_command"] = _data["name"]

elif _data.get("value") and _data.get("name"):
__kwargs[_data["name"]] = _data["value"]

Expand Down
1 change: 1 addition & 0 deletions interactions/api/models/message.py
Expand Up @@ -105,6 +105,7 @@ class Attachment(DictSerializerMixin):
"""

__slots__ = (
"_client",
"_json",
"id",
"filename",
Expand Down
2 changes: 1 addition & 1 deletion interactions/client.py
Expand Up @@ -399,7 +399,7 @@ def __check_sub_command(_sub_command: Option, _sub_group: Option = MISSING):
raise InteractionException(
11, message="Descriptions must be less than 100 characters."
)
if _sub_command.options is not MISSING:
if _sub_command.options is not MISSING and _sub_command.options:
if len(_sub_command.options) > 25:
raise InteractionException(
11, message="Your sub command must have less than 25 options."
Expand Down

0 comments on commit 66d1df5

Please sign in to comment.