discord.py icon indicating copy to clipboard operation
discord.py copied to clipboard

improve app_commands.Range parameter type checking and documentation

Open machineonamission opened this issue 3 years ago • 4 comments

Summary

the values passed for min and max for the Range are now properly checked against the given Range type. the original code just checked if the types of min and max were the same which doesn't work if both types are wrong and erroneously makes ints not work as min/max for float ranges.

I also improved the documentation as the original documentation didn't show examples for floats or strings.

Checklist

  • [x] If code changes were made then they have been tested.
    • [x] I have updated the documentation to reflect the changes.
  • [ ] This PR fixes an issue.
  • [ ] This PR adds something new (e.g. new method or parameters).
  • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • [ ] This PR is not a code change (e.g. documentation, README, ...)

machineonamission avatar Nov 05 '22 05:11 machineonamission

sidenote: might be useful to add an async def convert method to these for compatibility with hybrid/classic commands. i may do it myself in a PR later

machineonamission avatar Nov 05 '22 05:11 machineonamission

erroneously makes ints not work as min/max for float ranges.

That's by design.

Rapptz avatar Nov 05 '22 05:11 Rapptz

In my testing they work just fine. I realize it’s not hard to add “.0” after a number but I don’t feel it’s necessary

machineonamission avatar Nov 05 '22 05:11 machineonamission

If this pull is merged, I think similar changes should be applied to commands.Range as well I'll update the pull later

machineonamission avatar Nov 17 '22 23:11 machineonamission