Skip to content

Commit 06d1798

Browse files
Icebluewolfpre-commit-ci[bot]Dorukyum
authored andcommitted
fix: Single Member Enums Fail Converting To Option (Pycord-Development#2577)
* fix: Check If Enum Has Docstring Before Using It As Option Description * fix: Single Item Enums Of Invalid Types Not Converting To String * chore: Update Changelog * style(pre-commit): auto fixes from pre-commit.com hooks * chore: I Used The Wrong PR Number * Update discord/commands/options.py Co-authored-by: Dorukyum <[email protected]> Signed-off-by: Ice Wolfy <[email protected]> --------- Signed-off-by: Ice Wolfy <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <[email protected]>
1 parent e5becf0 commit 06d1798

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ These changes are available on the `master` branch, but have not yet been releas
2323
- Added `Member.guild_banner` and `Member.display_banner` properties.
2424
([#2556](https://github.com/Pycord-Development/pycord/pull/2556))
2525

26+
### Fixed
27+
28+
- Fix `Enum` options not setting the correct type when only one choice is available.
29+
([#2577](https://github.com/Pycord-Development/pycord/pull/2577))
30+
2631
### Changed
2732

2833
- Renamed `cover` property of `ScheduledEvent` and `cover` argument of
@@ -46,8 +51,8 @@ These changes are available on the `master` branch, but have not yet been releas
4651
([#2555](https://github.com/Pycord-Development/pycord/pull/2555))
4752
- Fixed missing `stacklevel` parameter in `warn_deprecated` function call inside
4853
`@utils.deprecated`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
49-
- Fixed the type hint in `ConnectionState._polls` to reflect actual behavior, changing it
50-
from `Guild` to `Poll`.
54+
- Fixed the type hint in `ConnectionState._polls` to reflect actual behavior, changing
55+
it from `Guild` to `Poll`.
5156
([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
5257
- Fixed missing `__slots__` attributes in `RawReactionClearEmojiEvent` and
5358
`RawMessagePollVoteEvent`.

discord/commands/options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def __init__(
198198
enum_choices = []
199199
input_type_is_class = isinstance(input_type, type)
200200
if input_type_is_class and issubclass(input_type, (Enum, DiscordEnum)):
201-
if description is None:
201+
if description is None and input_type.__doc__ is not None:
202202
description = inspect.cleandoc(input_type.__doc__)
203203
if description and len(description) > 100:
204204
description = description[:97] + "..."
@@ -209,7 +209,9 @@ def __init__(
209209
)
210210
enum_choices = [OptionChoice(e.name, e.value) for e in input_type]
211211
value_class = enum_choices[0].value.__class__
212-
if all(isinstance(elem.value, value_class) for elem in enum_choices):
212+
if value_class in SlashCommandOptionType.__members__ and all(
213+
isinstance(elem.value, value_class) for elem in enum_choices
214+
):
213215
input_type = SlashCommandOptionType.from_datatype(
214216
enum_choices[0].value.__class__
215217
)

0 commit comments

Comments
 (0)