Add defaults for auto-populated selects #1804
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add
default_values
attribute for auto-populated selects. This did require some fairly significant restructuring to make type-safe, and honestly I'm still not quite happy with the result, so feedback is welcome.The select types have been completely seperated, so the new hierarchy of components looks something like this:
This PR also deprecates
ActionRowBuilder.add_select_menu()
as type-specific methods have been added for each select type. I feel like seperating the select types is better for type safety and potentially more future-proof if Discord decides add specific behaviours to a given select type down the line.Example
I tried an alternative interface where the snowflake's type could be inferred from the select's type, however this is not possible due to it being possible to mix default types in mentionable selects, so at the moment this is the best I could come up with.
The implementation tries to be type-safe to the extent that adding an invalid default type fails type-checking:
Checklist
nox
and all the pipelines have passed.Related issues
Closes #1776