Skip to content

Commit 59ab5ec

Browse files
authored
fix: 🐛 Union type cannot be used in ctx. (#2611)
* 🐛 Union type cannot be used in `ctx`. * 📝 CHANGELOG.md
1 parent 7c7886e commit 59ab5ec

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ These changes are available on the `master` branch, but have not yet been releas
4848
([#2595](https://github.com/Pycord-Development/pycord/pull/2595))
4949
- Fixed `BucketType.category` cooldown commands not functioning correctly in private
5050
channels. ([#2603](https://github.com/Pycord-Development/pycord/pull/2603))
51+
- Fixed `SlashCommand`'s `ctx` parameter couldn't be `Union` type.
52+
([#2611](https://github.com/Pycord-Development/pycord/pull/2611))
5153

5254
### Changed
5355

discord/commands/options.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from ..utils import MISSING, basic_autocomplete
4646

4747
if TYPE_CHECKING:
48+
from ..commands import ApplicationContext
4849
from ..ext.commands import Converter
4950
from ..member import Member
5051
from ..message import Attachment
@@ -227,6 +228,13 @@ def __init__(
227228
else:
228229
from ..ext.commands import Converter
229230

231+
if isinstance(input_type, tuple) and any(
232+
issubclass(op, ApplicationContext) for op in input_type
233+
):
234+
input_type = next(
235+
op for op in input_type if issubclass(op, ApplicationContext)
236+
)
237+
230238
if (
231239
isinstance(input_type, Converter)
232240
or input_type_is_class

0 commit comments

Comments
 (0)