Skip to content

Commit ebf4b03

Browse files
authored
Fix KeyError when min_value or max_value are missing.
1 parent d85edf1 commit ebf4b03

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

discord/commands/commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ def __init__(
528528
for o in kwargs.pop("choices", list())
529529
]
530530
self.default = kwargs.pop("default", None)
531-
self.min_value: Optional[Union[int, float]] = kwargs.pop("min_value")
532-
self.max_value: Optional[Union[int, float]] = kwargs.pop("max_value")
531+
self.min_value: Optional[Union[int, float]] = kwargs.pop("min_value", None)
532+
self.max_value: Optional[Union[int, float]] = kwargs.pop("max_value", None)
533533

534534
if any([self.max_value, self.min_value]) and not self.input_type in {SlashCommandOptionType.integer, SlashCommandOptionType.number}:
535535
raise TypeError('min_value and max_value can only be set on options with of type integer or number.')
@@ -544,9 +544,9 @@ def to_dict(self) -> Dict:
544544
}
545545
if self.channel_types:
546546
as_dict["channel_types"] = [t.value for t in self.channel_types]
547-
if self.min_value:
547+
if self.min_value is not None:
548548
as_dict["min_value"] = self.min_value
549-
if self.max_value:
549+
if self.max_value is not None:
550550
as_dict["max_value"] = self.max_value
551551

552552
return as_dict

0 commit comments

Comments
 (0)