-
-
Notifications
You must be signed in to change notification settings - Fork 740
[Feature] Modal Select Components Support for IF #3189
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
Open
Cenngo
wants to merge
63
commits into
discord-net:dev
Choose a base branch
from
Cenngo:feature/modal-components-v2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…eneral purpose use
…odal extension methods
Upstream merge
…go/Discord.Net into feature/modal-components-v2
Misha-133
reviewed
Nov 13, 2025
Misha-133
reviewed
Nov 13, 2025
src/Discord.Net.Interactions/Builders/Modals/Components/RoleSelectComponentBuilder.cs
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds support for FileUpload, UserSelect, RoleSelect, ChannelSelect, MentionableSelect and SelectMenu to Interaction Framework.
To make modal generation/response flow more modular and make granular control possible, a new TypeConverter type called ModalComponentTypeConverter has been introduced. The new TypeConverter exposes a
WriteAsync<>()method to allow the alteration of input component parameters when aRespondWithModal<>()extension method is called. 4 default TypeConverters are included in this PR for the following types: Array, Enum, IConvertible, Nullable.With the default setup, User/Channel/Role/Mentionable select values can be automatically mapped to
IUser[]/IRole[]/IChannel[]arrays. For SelectMenu components, just like with message component SelectMenus, the converter falls back to a TypeReader for converting the returned string values to the underlying CLR type. Enums can be used to auto-populate SelectMenu options and returned values can be mapped to regular enums if a single-select is used, to flags enums if a multi-select is used.[HideAttribute]used for SlashCommand parameters, can be used to hide select enum values,and a new
[SelectMenuOptionAttribute]can be used to define description, emote, and IsDefault values for individul enum values. A new [ModalSelectMenuOptionAttribute] can be used on properties marked with [ModalSelectMenuInputAttribute] to add select menu options decleratively. Nullable types can be used which use the ModalComponentTypeConverter assigned to the underlying type for convertion. TextInput and single-select menu values can be converted toIConvertibletypes. Instance values of the component properties are used to supply the default values of components. The default behaviour of all of the converters is that they use the property value of the modal instance to populate their respective components' default values. As always, every default behaviour defined in the default typeconverters can be overridden by defining custom typecoverters for the respective clr type. Text display component cannot have any assigned typeconverters and must be a type of string, its content is populated using the property value of the instance and falls back to the content provided in the attribute. [HideAttribute] now features an overrideable Predicate() method to selectively hide enum options on runtime.Changes:
Breaking Changes: