Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Option raising AttributeError for str and min_length or max_length (issue #1526) #1527

Merged
merged 9 commits into from
Jul 26, 2022
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