serenity
serenity copied to clipboard
Sort slash command parameters by required-ness automatically
Parameters to slash commands (application commands) must be sent to Discord in such an order that required arguments come first and optional parameters after that. Not adhering to that order yields a Invalid Form Body
error from Discord.
I think it would be a good idea if serenity applied this order automatically when registering a slash command.
This detail is not documented it seems, but HarmoGlace and me both encountered it experimentally
The issue with sorting it in the library is that it will not be displayed in the same order as the developer wanted, which can seems weird for them if they are not aware.
With the new error system, it directly throws an error and you directly know that required fields must be passed before optional ones. I think that a note on the documentation should be enough, personnaly I wouldn't like a library to reorder my options, the current behavior seems the best in my opinion.
I can understand that point of view. FWIW to me the automatic re-ordering seems intuitive, in fact I previously assumed Discord did exactly that behind the scenes.
But of course I don't know if the majority of serenity users shares this opinion.