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

refactor: Minor parameter catching #463

Merged
merged 14 commits into from Feb 9, 2022
11 changes: 8 additions & 3 deletions interactions/client.py
Expand Up @@ -20,7 +20,7 @@
from .base import get_logger
from .decor import command
from .decor import component as _component
from .enums import ApplicationCommandType
from .enums import ApplicationCommandType, OptionType
from .models.command import ApplicationCommand, Option
from .models.component import Button, Modal, SelectMenu

Expand Down Expand Up @@ -361,6 +361,8 @@ def decorator(coro: Coroutine) -> Callable[..., Any]:
if name is MISSING:
raise InteractionException(11, message="Your command must have a name.")

# for _ in name: # detect uppercase

if type == ApplicationCommandType.CHAT_INPUT and description is MISSING:
raise InteractionException(
11, message="Chat-input commands must have a description."
Expand All @@ -378,10 +380,13 @@ def decorator(coro: Coroutine) -> Callable[..., Any]:
)
_option: Option
for _option in options:
if not _option._json.get("description"):
if not _option._json.get("description") and _option not in (
OptionType.SUB_COMMAND,
OptionType.SUB_COMMAND_GROUP,
):
V3ntus marked this conversation as resolved.
Show resolved Hide resolved
raise InteractionException(
11,
message="A description is required for Options"
message="A description is required for Options that are not sub-commands",
)

commands: List[ApplicationCommand] = command(
Expand Down