-
-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Labels
Milestone
Description
Summary
Statement from @Lulalaby:
Libs should be able to parse Option(discord.User) and make it Castable as member within the context of the current guild, If applicable.
Reproduction Steps
- Pass a
discord.Userto the type argument in adiscord.commands.Option().
Minimal Reproducible Code
import discord
...
discord.commands.Option(discord.User)Expected Results
Get a user object similar to the discord.Member class.
Actual Results
Traceback (most recent call last):
File "C:\Dev\Projects\bot.py", line 75, in <module>
discord.commands.Option(discord.User)
File "C:\Users\mendo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\commands.py", line 564, in __init__
_type = SlashCommandOptionType.from_datatype(input_type)
File "C:\Users\mendo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\enums.py", line 659, in from_datatype
raise TypeError(f'Invalid class {datatype} used as an input type for an Option')
TypeError: Invalid class <class 'discord.user.User'> used as an input type for an Option
Intents
Im not using intents.
System Information
- Python v3.10.0-final
- py-cord v2.0.0-alpha
- py-cord pkg_resources: v2.0.0a4214+g5a23a46
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.22000
(Actually, Windows 11 10.0.22000)
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
I was trying to make a Slash command with an Option(discord.Member) argument and it worked perfectly, except when someone called the command from the bot DM's.
Since it is a DM and there is no guild, the Option() class can not use the get_member() method from a NoneType. I tried to implement the @Lulalaby idea of using a discord.User instead and if the slash command was called from a guild, then get the discord.Member trough the user ID.