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!: prevent NoneType error during sub command checks and add kwarg for sub_commands without options #568

Merged
merged 10 commits into from Feb 26, 2022
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