Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 Union type cannot be used in ctx. #2611

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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