Skip to content
Open
1 change: 1 addition & 0 deletions changelog/1201.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|commands| Add support for ``Range[LargeInt, ...]`` in slash command parameters
4 changes: 2 additions & 2 deletions disnake/app_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def __init__(
self.required: bool = required
self.options: List[Option] = options or []

if min_value and self.type is OptionType.integer:
if min_value is not None and self.type is OptionType.integer:
min_value = math.ceil(min_value)
if max_value and self.type is OptionType.integer:
if max_value is not None and self.type is OptionType.integer:
max_value = math.floor(max_value)

self.min_value: Optional[float] = min_value
Expand Down
31 changes: 31 additions & 0 deletions disnake/ext/commands/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,37 @@ def __init__(self, argument: str) -> None:
super().__init__(f"{argument} is not able to be converted to an integer")


class LargeIntOutOfRange(BadArgument):
"""Exception raised when an argument to a large integer option exceeds given range.

This inherits from :exc:`BadArgument`

.. versionadded:: 2.11

Attributes
----------
argument: :class:`str`
The argument that exceeded the defined range.
min_value: Optional[Union[:class:`int`, :class:`float`]]
The minimum allowed value.
max_value: Optional[Union[:class:`int`, :class:`float`]]
The maximum allowed value.
"""

def __init__(
self,
argument: str,
min_value: Union[int, float, None],
max_value: Union[int, float, None],
) -> None:
self.argument: str = argument
self.min_value: Union[int, float, None] = min_value
self.max_value: Union[int, float, None] = max_value
a = "..." if min_value is None else min_value
b = "..." if max_value is None else max_value
super().__init__(f"{argument} is not in range [{a}, {b}]")


class DisabledCommand(CommandError):
"""Exception raised when the command being invoked is disabled.

Expand Down
Loading