-
-
Notifications
You must be signed in to change notification settings - Fork 40
feat: add radio and checkbox group components for modals #754
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
Conversation
Introduces DiscordRadioGroupComponent, DiscordCheckboxGroupComponent, and DiscordCheckboxComponent for modal-only usage, along with their option classes. Updates validation logic to restrict these components to modals, extends serialization and deserialization support, and adds new ComponentType enum values. Also adds builder methods to DiscordLabelComponent for attaching these new components.
5d95aee to
58a38df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces modal-only radio and checkbox components to DisCatSharp, expanding Discord's component system with new input types. The implementation adds three new component types (RadioGroup, CheckboxGroup, and Checkbox) along with their corresponding option classes, updates serialization/deserialization logic, adds validation to prevent these components from being used outside modals, and provides builder methods on DiscordLabelComponent for attaching these new components.
Changes:
- Added ComponentType enum values for CheckpointCard (20), RadioGroup (21), CheckboxGroup (22), and Checkbox (23)
- Implemented DiscordRadioGroupComponent, DiscordCheckboxGroupComponent, and DiscordCheckboxComponent with their respective option classes
- Extended serialization support in ILabelComponentJsonConverter and DiscordComponentJsonConverter
- Added modal-only validation logic to DisCatSharpBuilder and DiscordApiClient
- Added builder methods to DiscordLabelComponent (WithRadioGroupComponent, WithCheckboxGroupComponent, WithCheckboxComponent) and implemented GetChildren() override
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| DisCatSharp/Enums/Interaction/ComponentType.cs | Adds four new component type enum values (CheckpointCard, RadioGroup, CheckboxGroup, Checkbox) with XML documentation |
| DisCatSharp/Entities/Components/V2Components/DiscordRadioGroupComponent.cs | Implements radio group component with options list, custom ID, and required field support |
| DisCatSharp/Entities/Components/V2Components/DiscordRadioGroupComponentOption.cs | Defines radio group option class with label, value, description, and default flag |
| DisCatSharp/Entities/Components/V2Components/DiscordCheckboxGroupComponent.cs | Implements checkbox group component with min/max value constraints |
| DisCatSharp/Entities/Components/V2Components/DiscordCheckboxGroupComponentOption.cs | Defines checkbox group option class with label, value, description, and default flag |
| DisCatSharp/Entities/Components/V2Components/DiscordCheckboxComponent.cs | Implements single checkbox component with default state support |
| DisCatSharp/Entities/Components/DiscordLabelComponent.cs | Adds three new builder methods for attaching radio/checkbox components and implements GetChildren() to support component traversal |
| DisCatSharp/Net/Serialization/ILabelComponentJsonConverter.cs | Extends deserialization to handle RadioGroup, CheckboxGroup, and Checkbox component types |
| DisCatSharp/Net/Serialization/DiscordComponentJsonConverter.cs | Extends component instantiation to support the three new component types |
| DisCatSharp/Entities/Core/DisCatSharpBuilder.cs | Adds validation logic to prevent modal-only components from being used in non-modal contexts |
| DisCatSharp/Net/Rest/DiscordApiClient.cs | Updates modal response validation to allow RadioGroup, CheckboxGroup, and Checkbox component types |
DisCatSharp/Entities/Components/V2Components/DiscordCheckboxGroupComponent.cs
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-Authored-By: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Lulalaby <[email protected]>
Co-Authored-By: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Lulalaby <[email protected]>
Checkboxes can only be children of DiscordLabelComponent, not top-level modal components. This fixes the validation to properly allow checkboxes only when nested in labels. Co-Authored-By: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Lulalaby <[email protected]>
Co-Authored-By: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Lulalaby <[email protected]>
fix: address PR #754 review feedback - validation, grammar, and formatting
Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
Description
Introduces DiscordRadioGroupComponent, DiscordCheckboxGroupComponent, and DiscordCheckboxComponent for modal-only usage, along with their option classes. Updates validation logic to restrict these components to modals, extends serialization and deserialization support, and adds new ComponentType enum values. Also adds builder methods to DiscordLabelComponent for attaching these new components.
Type of change
Please delete options that are not relevant.
Checklist:
@Aiko-IT-Systems/discatsharp