Skip to content

Commit

Permalink
Fix Option raising AttributeError for str and `min_length or max_…
Browse files Browse the repository at this point in the history
…length` (#1527)

* Fix #1385

* key type fix (int => str)

* remove space

* fix issue discord.commands.Option while str and min/max_length were set
  • Loading branch information
yoggys authored Jul 26, 2022
1 parent c93c8ba commit ff92eb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ def __init__(self, input_type: InputType = str, /, description: Optional[str] =
self.min_length: Optional[int] = kwargs.pop("min_length", None)
self.max_length: Optional[int] = kwargs.pop("max_length", None)

if (input_type != SlashCommandOptionType.integer and input_type != SlashCommandOptionType.number
if (self.input_type != SlashCommandOptionType.integer and self.input_type != SlashCommandOptionType.number
and (self.min_value or self.max_value)):
raise AttributeError("Option does not take min_value or max_value if not of type "
"SlashCommandOptionType.integer or SlashCommandOptionType.number")
if input_type != SlashCommandOptionType.string and (self.min_length or self.max_length):
if self.input_type != SlashCommandOptionType.string and (self.min_length or self.max_length):
raise AttributeError('Option does not take min_length or max_length if not of type str')

if self.min_value is not None and not isinstance(self.min_value, minmax_types):
Expand Down

0 comments on commit ff92eb6

Please sign in to comment.