From 341fcce6b272b15c2740971d7832f2e0e69dd72d Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 15 Sep 2024 15:53:00 -0400 Subject: [PATCH 1/6] fix: Check If Enum Has Docstring Before Using It As Option Description --- discord/commands/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index 721a03ffe3..e6db9090be 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -198,7 +198,7 @@ def __init__( enum_choices = [] input_type_is_class = isinstance(input_type, type) if input_type_is_class and issubclass(input_type, (Enum, DiscordEnum)): - if description is None: + if description is None and input_type.__doc__ is not None: description = inspect.cleandoc(input_type.__doc__) if description and len(description) > 100: description = description[:97] + "..." From e328249fa6ae3f7e9d2f03c6d7059751ba57ea75 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 15 Sep 2024 21:01:16 -0400 Subject: [PATCH 2/6] fix: Single Item Enums Of Invalid Types Not Converting To String --- discord/commands/options.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index e6db9090be..06b15f82ed 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -209,7 +209,8 @@ def __init__( ) enum_choices = [OptionChoice(e.name, e.value) for e in input_type] value_class = enum_choices[0].value.__class__ - if all(isinstance(elem.value, value_class) for elem in enum_choices): + if (enum_choices[0].value.__class__ in SlashCommandOptionType.__members__ and + all(isinstance(elem.value, value_class) for elem in enum_choices)): input_type = SlashCommandOptionType.from_datatype( enum_choices[0].value.__class__ ) From 7fb1a4b07c1f4b2149a473f5287c0df2fa877474 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 15 Sep 2024 21:09:26 -0400 Subject: [PATCH 3/6] chore: Update Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3314006319..0eaa86f65f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ These changes are available on the `master` branch, but have not yet been releas - Added `Member.guild_banner` and `Member.display_banner` properties. ([#2556](https://github.com/Pycord-Development/pycord/pull/2556)) +### Fixed +- Fix `Enum` options not setting the correct type when only one choice is available. + ([#2575](https://github.com/Pycord-Development/pycord/pull/2575)) + ### Changed - Renamed `cover` property of `ScheduledEvent` and `cover` argument of From 8805303f7652fdffa7f22b7a0933ac7ac33da71f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 01:16:42 +0000 Subject: [PATCH 4/6] style(pre-commit): auto fixes from pre-commit.com hooks --- CHANGELOG.md | 5 +++-- discord/commands/options.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eaa86f65f..7f2ec26349 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2556](https://github.com/Pycord-Development/pycord/pull/2556)) ### Fixed + - Fix `Enum` options not setting the correct type when only one choice is available. ([#2575](https://github.com/Pycord-Development/pycord/pull/2575)) @@ -50,8 +51,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2555](https://github.com/Pycord-Development/pycord/pull/2555)) - Fixed missing `stacklevel` parameter in `warn_deprecated` function call inside `@utils.deprecated`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) -- Fixed the type hint in `ConnectionState._polls` to reflect actual behavior, changing it - from `Guild` to `Poll`. +- Fixed the type hint in `ConnectionState._polls` to reflect actual behavior, changing + it from `Guild` to `Poll`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500)) - Fixed missing `__slots__` attributes in `RawReactionClearEmojiEvent` and `RawMessagePollVoteEvent`. diff --git a/discord/commands/options.py b/discord/commands/options.py index 06b15f82ed..81a3484771 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -209,8 +209,11 @@ def __init__( ) enum_choices = [OptionChoice(e.name, e.value) for e in input_type] value_class = enum_choices[0].value.__class__ - if (enum_choices[0].value.__class__ in SlashCommandOptionType.__members__ and - all(isinstance(elem.value, value_class) for elem in enum_choices)): + if enum_choices[ + 0 + ].value.__class__ in SlashCommandOptionType.__members__ and all( + isinstance(elem.value, value_class) for elem in enum_choices + ): input_type = SlashCommandOptionType.from_datatype( enum_choices[0].value.__class__ ) From 35d44e757e66e0c5a6ee6bc9b27d237d4d317c13 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sun, 15 Sep 2024 21:22:08 -0400 Subject: [PATCH 5/6] chore: I Used The Wrong PR Number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eaa86f65f..9ad9f5b720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ These changes are available on the `master` branch, but have not yet been releas ### Fixed - Fix `Enum` options not setting the correct type when only one choice is available. - ([#2575](https://github.com/Pycord-Development/pycord/pull/2575)) + ([#2577](https://github.com/Pycord-Development/pycord/pull/2577)) ### Changed From cdd3ca14611a864accf87fd7eead21f4843e087c Mon Sep 17 00:00:00 2001 From: Ice Wolfy <44532864+Icebluewolf@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:55:53 -0500 Subject: [PATCH 6/6] Update discord/commands/options.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Ice Wolfy <44532864+Icebluewolf@users.noreply.github.com> --- discord/commands/options.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index 81a3484771..382067421f 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -209,9 +209,7 @@ def __init__( ) enum_choices = [OptionChoice(e.name, e.value) for e in input_type] value_class = enum_choices[0].value.__class__ - if enum_choices[ - 0 - ].value.__class__ in SlashCommandOptionType.__members__ and all( + if value_class in SlashCommandOptionType.__members__ and all( isinstance(elem.value, value_class) for elem in enum_choices ): input_type = SlashCommandOptionType.from_datatype(