From fd9c244f480ae12f972daf2ffe34ae83125847fe Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 3 Jul 2022 07:37:48 -0400 Subject: [PATCH] Validate Range to disallow min > max --- discord/app_commands/transformers.py | 3 +++ discord/ext/commands/converter.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/discord/app_commands/transformers.py b/discord/app_commands/transformers.py index cb5372ea6..bf3998b78 100644 --- a/discord/app_commands/transformers.py +++ b/discord/app_commands/transformers.py @@ -310,6 +310,9 @@ def _make_range_transformer( min: Optional[Union[int, float]] = None, max: Optional[Union[int, float]] = None, ) -> Type[Transformer]: + if min and max and min > max: + raise TypeError('minimum cannot be larger than maximum') + ns = { 'type': classmethod(lambda _: opt_type), 'min_value': classmethod(lambda _: min), diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 81a413fb0..968c9e70e 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -1081,6 +1081,9 @@ else: self.min: Optional[Union[int, float]] = min self.max: Optional[Union[int, float]] = max + if min and max and min > max: + raise TypeError('minimum cannot be larger than maximum') + async def convert(self, ctx: Context[BotT], value: str) -> Union[int, float]: count = converted = self.annotation(value) if self.annotation is str: