Skip to content

Commit 4f3a729

Browse files
Paillat-devpre-commit-ci[bot]Lulalaby
committed
fix: 🐛 Issue in @option where some annotations could not be used along with channel_types (Pycord-Development#2835)
* 🐛 Option: Always set `input_type` to `SlashCommandOptionType.channel` when `channel_types` is set * 📝 CHANGELOG.md * style(pre-commit): auto fixes from pre-commit.com hooks --------- Signed-off-by: Paillat <[email protected]> Signed-off-by: Lala Sabathil <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil <[email protected]> (cherry picked from commit 213b639)
1 parent 6fe0978 commit 4f3a729

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ These changes are available on the `master` branch, but have not yet been releas
123123
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
124124
- Fixed `AttributeError` when printing a File component's `__repr__`.
125125
([#2843](https://github.com/Pycord-Development/pycord/pull/2843))
126+
- Fixed `TypeError` when using `@option` with certain annotations and along with
127+
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
126128

127129
### Changed
128130

discord/commands/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ def __init__(self, input_type: InputType = str, /, description: str | None = Non
221221
self.description = description or "No description provided"
222222
self.channel_types: list[ChannelType] = kwargs.pop("channel_types", [])
223223

224-
if isinstance(input_type, SlashCommandOptionType):
224+
if self.channel_types:
225+
self.input_type = SlashCommandOptionType.channel
226+
elif isinstance(input_type, SlashCommandOptionType):
225227
self.input_type = input_type
226228
else:
227229
from ..ext.commands import Converter # noqa: PLC0415

0 commit comments

Comments
 (0)