Skip to content

Commit

Permalink
fix: 🐛 Union type cannot be used in ctx. (#2611)
Browse files Browse the repository at this point in the history
* 🐛 Union type cannot be used in `ctx`.

* 📝 CHANGELOG.md
  • Loading branch information
Paillat-dev authored Oct 29, 2024
1 parent 7c7886e commit 59ab5ec
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 @@ -45,6 +45,7 @@
from ..utils import MISSING, basic_autocomplete

if TYPE_CHECKING:
from ..commands import ApplicationContext
from ..ext.commands import Converter
from ..member import Member
from ..message import Attachment
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 59ab5ec

Please sign in to comment.