disnake icon indicating copy to clipboard operation
disnake copied to clipboard

combine commands.LargeInt with commands.Range

Open onerandomusername opened this issue 1 year ago • 2 comments

Summary

LargeInt cannot be restricted like Range, and Range cannot be a big int.

What is the feature request for?

disnake.ext.commands

The Problem

LargeInt is an integer bigger than 2 ** 53, and Range only works on numbers below 2 ** 53. It would be nice to have a combination of the two, possibly even merge them into one class.

We also don't have LargeFloat right now, so a modified Range could potentially support that.

The Ideal Solution

Continue to keep LargeInt around, but merge support into Range. This means that if Range has more than the limit provided by discord, we instead use an underlying string type and manually compute the value. In order to constrain the value further, we should provide min_length and max_length computed to the length of the object.

For example:

# setup variables
# for those wondering, these are the shortest and current longest possible snowflake values
min = int("1" + "0" * 16)
max = int("9" * 19)


commands.Range[min, max] 

This would create a Range object that is rendered as a string but has a min_length set to 17, and a max_length set to 19, as that is how long the beginning number and second number are after converted to a string. After that we would compute the limitations as normal once we received an interaction. We should also keep in mind https://github.com/python/cpython/issues/95778

The Current Solution

None

Additional Context

No response

onerandomusername avatar Oct 03 '22 18:10 onerandomusername

I would like to implement this!

EmmmaTech avatar Nov 07 '22 04:11 EmmmaTech