Skip to content

Add checkboxes, checkbox groups and radio groups#253

Open
freya022 wants to merge 13 commits into3.Xfrom
feature/radio-groups-and-checkboxes
Open

Add checkboxes, checkbox groups and radio groups#253
freya022 wants to merge 13 commits into3.Xfrom
feature/radio-groups-and-checkboxes

Conversation

@freya022
Copy link
Owner

@freya022 freya022 commented Jan 22, 2026

This adds support for reading values in modal handlers, and Kotlin extensions + DSL builders for the new modals components.

Values of those new components can now be read as:

  • Checkbox -> Boolean
  • CheckboxGroup -> List<String>, String
  • RadioGroup -> String
Example command
private const val MODAL_NAME = "SlashModal: modal"
private const val CHECKBOX_ID = "checkbox-id"
private const val RADIO_GROUP_ID = "radio_group-id"
private const val CHECKBOX_GROUP_ID = "checkbox_group-id"

@Command
class SlashModal(private val modals: Modals) {
    @JDASlashCommand(name = "modal", description = "Test new modal features!")
    fun onSlashModal(event: GuildSlashEvent) {
        val modal = modals.create("Modal") {
            label("I like checking boxes") {
                child = Checkbox(CHECKBOX_ID, isDefault = true)
            }

            label("Which Discord client do you use?") {
                child = RadioGroup(RADIO_GROUP_ID) {
                    option("Discord (Stable)", "stable", "The vanilla option", default = true)
                    option("Discord PTB", "ptb", "A peek into the future")
                    option("Discord Canary", "canary", "Living on the edge")
                }
            }

            label("Which modal components do you use?") {
                child = CheckboxGroup(CHECKBOX_GROUP_ID) {
                    option("Text Inputs", "textinputs")
                    option("Select Menus", "selectmenus")
                    option("File Uploads", "fileuploads")
                    option("Checkbox groups", "checkboxgroups", default = true)
                }
            }

            bindTo(MODAL_NAME)
        }

        event.replyModal(modal).queue()
    }

    @ModalHandler(MODAL_NAME)
    fun onModal(
        event: ModalEvent,
        @ModalInput(CHECKBOX_ID) doTheyLikeCheckingBoxes: Boolean,
        @ModalInput(RADIO_GROUP_ID) client: String,
        @ModalInput(CHECKBOX_GROUP_ID) features: List<String>,
    ) {
        event.reply("""
            Do you like checking boxes? $doTheyLikeCheckingBoxes
            On what client? $client
            Using what features? $features
        """.trimIndent())
            .setEphemeral(true)
            .queue()
    }
}

JDA PR: discord-jda/JDA#3010

@freya022 freya022 force-pushed the feature/radio-groups-and-checkboxes branch from 968694f to fbdf8c1 Compare January 27, 2026 14:38
@freya022 freya022 force-pushed the feature/radio-groups-and-checkboxes branch 2 times, most recently from c3caad0 to 5a8f699 Compare February 15, 2026 11:24
@freya022 freya022 force-pushed the feature/radio-groups-and-checkboxes branch from 5a8f699 to ac956c2 Compare February 17, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant