New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add number to ApplicationCommandOption #1450
Add number to ApplicationCommandOption #1450
Conversation
Not sure if one should enforce the range in the library, when adding options. It does cause an issue when a choice of a larger number, e.g.
Discord handles larger doubles in their frontend, so receiving it from user-input is not an issue. I could change the |
In my opinion, you should not change your actual implementation to add some checks in the builder. It would be inconsistent, as for instance you can provide strings which are considered as invalid by discord but not by the library. However you can also choose to make your own type, even if I think that it wouldn't be very useful. |
Yeah, the I think with the strings you would get an api-error (invalid-form) or it fixes it silently (I think with emoji-names?), but with the number here it fails silently and can cause an issue later on. I would be all for enforcing it in the library, but I'm not sure if it's feasible with keeping it up to date. For example, the embed-description-limit was raised from 2048 to 4096 recently, which is only noted in the docs (which needs updating as well.) I can just add a note about the current limit to the method, if you want. |
Well it is a discord issue if their API accepts an invalid number, it should be reported. A silent fail isn't good I agree |
Hey, sorry for reopening, but I looked a bit more into it, and Discord is returning a string instead of a number when the choice-value is too large. So it could possibly be handled. But as it's outside of the documented supported range, it's undefined behaviour. Funnily enough, if I create this command with the too-large number-choice in a different library (discord.js), I get an error when selecting the choice in the Discord-UI, so a user-facing error:
I don't know why this is different, but that's even worse.
I think it was already discussed in the discord-api-docs-repo in several issues, so I don't think there is much use in asking them to reject these inputs. Should I add handling for the string-case? Or is it fine to keep it the way it is? If the latter, please close again, and thanks for the guidance 👍 |
Hello!
This commit adds NUMBER to the ApplicationCommandOption.
It also adds a method to the builder for adding it as a choice.