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

Slash command with Option of type str and min/max_length raise AttributeError #1526

Closed
3 tasks done
yoggys opened this issue Jul 26, 2022 · 2 comments
Closed
3 tasks done
Labels
unconfirmed bug A bug report that needs triaging

Comments

@yoggys
Copy link
Contributor

yoggys commented Jul 26, 2022

Summary

Slash command with Option of type str and min/max length values raise AttributeError
Bot fails when trying to load a cog that has such command.

Reproduction Steps

Create slash commands with Option of type str and min/max length and try to register it

Minimal Reproducible Code

@commands.slash_command()
    async def test(
        self, ctx: discord.ApplicationContext,
        message: Option(str, min_length=1, max_length=1024),
    ):
        ...

Expected Results

The option should be accepted correctly

Actual Results

Traceback (most recent call last):
  File "/home/*/.local/lib/python3.8/site-packages/discord/cog.py", line 730, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/*/ybr/cogs/*.py", line 14, in <module>
    class *(commands.Cog):
  File "/home/*/ybr/cogs/*.py", line 61, in *
    message: Option(str, "*", min_length=1, max_length=1024),
  File "/home/*/.local/lib/python3.8/site-packages/discord/commands/options.py", line 247, in __init__
    raise AttributeError('Option does not take min_length or max_length if not of type str')
AttributeError: Option does not take min_length or max_length if not of type str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    client = *()
  File "/home/*/ybr/utils/client.py", line 26, in __init__
    self.load_extension('cogs.*')
  File "/home/*/.local/lib/python3.8/site-packages/discord/cog.py", line 850, in load_extension
    self._load_from_module_spec(spec, name)
  File "/home/*/.local/lib/python3.8/site-packages/discord/cog.py", line 733, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.*' raised an error: AttributeError: Option does not take min_length or max_length if not of type str

Intents

discord.Intents.all()

System Information

  • Python v3.8.13-final
  • py-cord v2.0.0-final
  • aiohttp v3.8.1
  • system info: Linux 5.4.0-122-generic Merge restructure into slash #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@yoggys
Copy link
Contributor Author

yoggys commented Jul 26, 2022

WHOOPS i pasted wrong Traceback, edited.

@Dorukyum
Copy link
Member

Fixed in #1527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants