Skip to content

Commit d85edf1

Browse files
authored
Add min_value & max_value to Option
1 parent 96ed955 commit d85edf1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

discord/commands/commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,11 @@ 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")
533+
534+
if any([self.max_value, self.min_value]) and not self.input_type in {SlashCommandOptionType.integer, SlashCommandOptionType.number}:
535+
raise TypeError('min_value and max_value can only be set on options with of type integer or number.')
531536

532537
def to_dict(self) -> Dict:
533538
as_dict = {
@@ -539,6 +544,10 @@ def to_dict(self) -> Dict:
539544
}
540545
if self.channel_types:
541546
as_dict["channel_types"] = [t.value for t in self.channel_types]
547+
if self.min_value:
548+
as_dict["min_value"] = self.min_value
549+
if self.max_value:
550+
as_dict["max_value"] = self.max_value
542551

543552
return as_dict
544553

0 commit comments

Comments
 (0)