Skip to content

Commit 7e7cbdd

Browse files
Paillat-devLulalaby
authored andcommitted
fix: 🐛 Union type cannot be used in ctx. (#2611)
1 parent 7c7886e commit 7e7cbdd

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
@@ -39,6 +39,7 @@
3939
Thread,
4040
VoiceChannel,
4141
)
42+
from ..commands import ApplicationContext
4243
from ..enums import ChannelType
4344
from ..enums import Enum as DiscordEnum
4445
from ..enums import SlashCommandOptionType
@@ -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)