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

multiple-type arg option is beak #991

Closed
3 tasks done
Asherlam opened this issue Feb 11, 2022 · 3 comments · Fixed by #1000
Closed
3 tasks done

multiple-type arg option is beak #991

Asherlam opened this issue Feb 11, 2022 · 3 comments · Fixed by #1000
Labels
unconfirmed bug A bug report that needs triaging

Comments

@Asherlam
Copy link

Asherlam commented Feb 11, 2022

Summary

Cannot set multiple type for arg in slash command

Reproduction Steps

@slash_command()
async def test(self, ctx, channel: Option([discord.TextChannel, discord.VoiceChannel])):
    print(channel)

Minimal Reproducible Code

Traceback (most recent call last):
  File "C:\Users\Andrew\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 705, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\Andrew\Documents\tuflya\cogs\sendmsg.py", line 8, in <module>
    class sendmsg(commands.Cog):
  File "c:\Users\Andrew\Documents\tuflya\cogs\sendmsg.py", line 14, in sendmsg
    channel: Option([discord.TextChannel, discord.VoiceChannel], "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u043d\u0430\u043b"),
  File "C:\Users\Andrew\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\options.py", line 72, in __init__
    _type = SlashCommandOptionType.from_datatype(input_type)
  File "C:\Users\Andrew\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\enums.py", line 670, in from_datatype
    if datatype.__name__ in ["Member", "User"]:
AttributeError: 'list' object has no attribute '__name__'. Did you mean: '__ne__'?

Expected Results

channel arg should accept both types

Actual Results

can't use multiple-type in slash command

Intents

default, members

System Information

Python Version: 3.10
Pycord Version: 2.0.0b4

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

@Asherlam Asherlam added the unconfirmed bug A bug report that needs triaging label Feb 11, 2022
@Ratery
Copy link
Contributor

Ratery commented Feb 11, 2022

Try to pass a tuple of channel types, not a list of them.
I'm going to open a PR to accept lists of channel types.

@IamMusavaRibica
Copy link

IamMusavaRibica commented Feb 11, 2022

Have you tried SlashCommandOptionType.channel (for your use case)?

@Asherlam
Copy link
Author

Try to pass a tuple of channel types, not a list of them. I'm going to open a PR to accept lists of channel types.

So they should update their example
https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_options.py#L25

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

Successfully merging a pull request may close this issue.

3 participants