Skip to content
This repository was archived by the owner on Aug 28, 2019. It is now read-only.

Commit fd9c244

Browse files
committed
Validate Range to disallow min > max
1 parent c61e407 commit fd9c244

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

discord/app_commands/transformers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ def _make_range_transformer(
310310
min: Optional[Union[int, float]] = None,
311311
max: Optional[Union[int, float]] = None,
312312
) -> Type[Transformer]:
313+
if min and max and min > max:
314+
raise TypeError('minimum cannot be larger than maximum')
315+
313316
ns = {
314317
'type': classmethod(lambda _: opt_type),
315318
'min_value': classmethod(lambda _: min),

discord/ext/commands/converter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,9 @@ def __init__(
10811081
self.min: Optional[Union[int, float]] = min
10821082
self.max: Optional[Union[int, float]] = max
10831083

1084+
if min and max and min > max:
1085+
raise TypeError('minimum cannot be larger than maximum')
1086+
10841087
async def convert(self, ctx: Context[BotT], value: str) -> Union[int, float]:
10851088
count = converted = self.annotation(value)
10861089
if self.annotation is str:

0 commit comments

Comments
 (0)