Repository: Pycord-Development/pycord

Issue:
Issues with #729
### Summary

PR #729 appears to have broken passing a SlashCommandOptionType to input_type in Option.

### Reproduction Steps

Create a slash command with an option, and set the option's type to one of the values in the SlashCommandOptionType enum.

### Minimal Reproducible Code

```python
 ​    ​@​commands​.​command​( 
 ​        ​name​=​'userinfo'​, 
 ​        ​description​=​"Displays information on a user."​, 
 ​        ​options​=​[ 
 ​            ​discord​.​Option​( 
 ​                ​SlashCommandOptionType​.​user​, 
 ​                ​name​=​"user"​, 
 ​                ​description​=​"The user to get information on."​, 
 ​                ​required​=​False​, 
 ​                ​default​=​None 
 ​            ) 
 ​        ] 
 ​    ) 
 ​    ​async​ ​def​ ​userinfo​(​self​, ​ctx​​, *, ​user​: ​​discord​.​Member​ ​=​ ​None​):
        ...
```


### Expected Results

Option is created and added to command with the appropriate input type.

### Actual Results

An exception is raised:
```
Traceback (most recent call last):
  ...
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 993, in wrap
    command = SlashCommand(func, parent=self, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 536, in __init__
    self.options: List[Option] = self._match_option_param_names(params, kwop)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in _match_option_param_names
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in <genexpr>
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 632, in <lambda>
    lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o.input_type],  # type: ignore (union types)
  File "/usr/local/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.9/typing.py", line 354, in __getitem__
    return self._getitem(self, parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in Union
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 166, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Union[arg, ...]: each arg must be a type. Got 3.
```

### Intents

Default

### System Information

On mobile, will update when able

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_
Issues with #729
### Summary

PR #729 appears to have broken passing a SlashCommandOptionType to input_type in Option.

### Reproduction Steps

Create a slash command with an option, and set the option's type to one of the values in the SlashCommandOptionType enum.

### Minimal Reproducible Code

```python
 ​    ​@​commands​.​command​( 
 ​        ​name​=​'userinfo'​, 
 ​        ​description​=​"Displays information on a user."​, 
 ​        ​options​=​[ 
 ​            ​discord​.​Option​( 
 ​                ​SlashCommandOptionType​.​user​, 
 ​                ​name​=​"user"​, 
 ​                ​description​=​"The user to get information on."​, 
 ​                ​required​=​False​, 
 ​                ​default​=​None 
 ​            ) 
 ​        ] 
 ​    ) 
 ​    ​async​ ​def​ ​userinfo​(​self​, ​ctx​​, *, ​user​: ​​discord​.​Member​ ​=​ ​None​):
        ...
```


### Expected Results

Option is created and added to command with the appropriate input type.

### Actual Results

An exception is raised:
```
Traceback (most recent call last):
  ...
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 993, in wrap
    command = SlashCommand(func, parent=self, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 536, in __init__
    self.options: List[Option] = self._match_option_param_names(params, kwop)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in _match_option_param_names
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in <genexpr>
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 632, in <lambda>
    lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o.input_type],  # type: ignore (union types)
  File "/usr/local/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.9/typing.py", line 354, in __getitem__
    return self._getitem(self, parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in Union
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 166, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Union[arg, ...]: each arg must be a type. Got 3.
```

### Intents

Default

### System Information

On mobile, will update when able

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_
Issues with #729
### Summary

PR #729 appears to have broken passing a SlashCommandOptionType to input_type in Option.

### Reproduction Steps

Create a slash command with an option, and set the option's type to one of the values in the SlashCommandOptionType enum.

### Minimal Reproducible Code

```python
 ​    ​@​commands​.​command​( 
 ​        ​name​=​'userinfo'​, 
 ​        ​description​=​"Displays information on a user."​, 
 ​        ​options​=​[ 
 ​            ​discord​.​Option​( 
 ​                ​SlashCommandOptionType​.​user​, 
 ​                ​name​=​"user"​, 
 ​                ​description​=​"The user to get information on."​, 
 ​                ​required​=​False​, 
 ​                ​default​=​None 
 ​            ) 
 ​        ] 
 ​    ) 
 ​    ​async​ ​def​ ​userinfo​(​self​, ​ctx​​, *, ​user​: ​​discord​.​Member​ ​=​ ​None​):
        ...
```


### Expected Results

Option is created and added to command with the appropriate input type.

### Actual Results

An exception is raised:
```
Traceback (most recent call last):
  ...
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 993, in wrap
    command = SlashCommand(func, parent=self, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 536, in __init__
    self.options: List[Option] = self._match_option_param_names(params, kwop)
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in _match_option_param_names
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 647, in <genexpr>
    if not any(c(o, p_obj) for c in check_annotations):
  File "/usr/local/lib/python3.9/site-packages/discord/commands/core.py", line 632, in <lambda>
    lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o.input_type],  # type: ignore (union types)
  File "/usr/local/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.9/typing.py", line 354, in __getitem__
    return self._getitem(self, parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in Union
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 466, in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/local/lib/python3.9/typing.py", line 166, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Union[arg, ...]: each arg must be a type. Got 3.
```

### Intents

Default

### System Information

On mobile, will update when able

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:
I think you mean PR #729
> I think you mean PR #729

nobody saw that
I think you mean PR #729
> I think you mean PR #729

nobody saw that
I think you mean PR #729
> I think you mean PR #729

nobody saw that

Resolving patch:
diff --git a/discord/commands/core.py b/discord/commands/core.py
--- a/discord/commands/core.py
+++ b/discord/commands/core.py
@@ -629,6 +629,7 @@ def _match_option_param_names(self, params, options):
 
         check_annotations = [
             lambda o, a: o.input_type == SlashCommandOptionType.string and o.converter is not None,  # pass on converters
+            lambda o, a: isinstance(o.input_type, SlashCommandOptionType),  # pass on slash cmd option type enums
             lambda o, a: isinstance(o._raw_type, tuple) and a == Union[o._raw_type],  # type: ignore (union types)
             lambda o, a: self._is_typing_optional(a) and not o.required and o._raw_type in a.__args__,  # optional
             lambda o, a: inspect.isclass(a) and issubclass(a, o._raw_type)  # 'normal' types
diff --git a/discord/commands/options.py b/discord/commands/options.py
--- a/discord/commands/options.py
+++ b/discord/commands/options.py
@@ -38,7 +38,7 @@ def __init__(self, input_type: Any, /, description: str = None, **kwargs) -> Non
         self.description = description or "No description provided"
         self.converter = None
         self._raw_type = input_type
-        self.channel_types: List[SlashCommandOptionType] = kwargs.pop(
+        self.channel_types: List[ChannelType] = kwargs.pop(
             "channel_types", []
         )
         if not isinstance(input_type, SlashCommandOptionType):


Test patch: