Skip to content

Commit

Permalink
chore(bridge): use BridgeOption instead of Option (#2252)
Browse files Browse the repository at this point in the history
* chore(bridge): force BridgeOption

* docs: updates

Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>

* style(pre-commit): auto fixes from pre-commit.com hooks

* fix: export `BridgeContext`

* fix: I might have dyslexia

Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>

* docs: better

* docs: add changelog entry

---------

Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 25, 2024
1 parent 6632e6f commit 2731d21
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -115,6 +115,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
- Changed the support from `orjson` to `msgspec` in the codebase.
([#2170](https://github.com/Pycord-Development/pycord/pull/2170))
- `BridgeOption` must now be used for arguments in bridge commands.
([#2252](https://github.com/Pycord-Development/pycord/pull/2252))

### Removed

Expand Down
9 changes: 5 additions & 4 deletions discord/ext/bridge/core.py
Expand Up @@ -66,6 +66,7 @@
"BridgeSlashCommand",
"BridgeExtGroup",
"BridgeSlashGroup",
"BridgeOption",
"map_to",
"guild_only",
"has_permissions",
Expand Down Expand Up @@ -591,6 +592,10 @@ async def convert(self, ctx, arg: bool):


class BridgeOption(Option, Converter):
"""A subclass of :class:`discord.Option` which represents a selectable slash
command option and a prefixed command argument for bridge commands.
"""

async def convert(self, ctx, argument: str) -> Any:
try:
if self.converter is not None:
Expand Down Expand Up @@ -621,7 +626,3 @@ async def convert(self, ctx, argument: str) -> Any:
return converted
except ValueError as exc:
raise BadArgument() from exc


discord.commands.options.Option = BridgeOption
discord.Option = BridgeOption
11 changes: 11 additions & 0 deletions docs/ext/bridge/api.rst
Expand Up @@ -157,3 +157,14 @@ BridgeContext Subclasses
.. data:: discord.ext.bridge.Context

Alias of :data:`typing.Union` [ :class:`.BridgeExtContext`, :class:`.BridgeApplicationContext` ] for typing convenience.

Option
------

BridgeOption
~~~~~~~~~~~~

.. attributetable:: discord.ext.bridge.BridgeOption

.. autoclass:: discord.ext.bridge.BridgeOption
:members:

0 comments on commit 2731d21

Please sign in to comment.