Skip to content

Commit

Permalink
fix: 🐛 Union type cannot be used in ctx. (Pycord-Development#2611)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paillat-dev authored and Lulalaby committed Oct 29, 2024
1 parent 7c7886e commit 7e7cbdd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2595](https://github.com/Pycord-Development/pycord/pull/2595))
- Fixed `BucketType.category` cooldown commands not functioning correctly in private
channels. ([#2603](https://github.com/Pycord-Development/pycord/pull/2603))
- Fixed `SlashCommand`'s `ctx` parameter couldn't be `Union` type.
([#2611](https://github.com/Pycord-Development/pycord/pull/2611))

### Changed

Expand Down
8 changes: 8 additions & 0 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Thread,
VoiceChannel,
)
from ..commands import ApplicationContext
from ..enums import ChannelType
from ..enums import Enum as DiscordEnum
from ..enums import SlashCommandOptionType
Expand Down Expand Up @@ -227,6 +228,13 @@ def __init__(
else:
from ..ext.commands import Converter

if isinstance(input_type, tuple) and any(
issubclass(op, ApplicationContext) for op in input_type
):
input_type = next(
op for op in input_type if issubclass(op, ApplicationContext)
)

if (
isinstance(input_type, Converter)
or input_type_is_class
Expand Down

0 comments on commit 7e7cbdd

Please sign in to comment.