Skip to content

chore!: 🔥 Remove deprecated support for Option in bridge commands #2731

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ These changes are available on the `master` branch, but have not yet been releas
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))

### Removed

- Removed deprecated support for `Option` in `BridgeCommand`. Use `BridgeOption`
instead. ([#2731])(https://github.com/Pycord-Development/pycord/pull/2731))

## [2.6.1] - 2024-09-15

### Fixed
Expand Down
20 changes: 3 additions & 17 deletions discord/ext/bridge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,12 @@ class BridgeExtCommand(Command):
def __init__(self, func, **kwargs):
super().__init__(func, **kwargs)

# TODO: v2.7: Remove backwards support for Option in bridge commands.
for name, option in self.params.items():
for option in self.params.values():
if isinstance(option.annotation, Option) and not isinstance(
option.annotation, BridgeOption
):
# Warn not to do this
warn_deprecated(
"Using Option for bridge commands",
"BridgeOption",
"2.5",
"2.7",
reference="https://github.com/Pycord-Development/pycord/pull/2417",
stacklevel=6,
)
# Override the convert method of the parameter's annotated Option.
# We can use the convert method from BridgeOption, and bind "self"
# using a manual invocation of the descriptor protocol.
# Definitely not a good approach, but gets the job done until removal.
self.params[name].annotation.convert = BridgeOption.convert.__get__(
self.params[name].annotation
raise TypeError(
f"{option.annotation.__class__.__name__} is not supported in bridge commands. Use BridgeOption instead."
)

async def dispatch_error(self, ctx: BridgeExtContext, error: Exception) -> None:
Expand Down