Skip to content

Conversation

@freya022
Copy link
Owner

@freya022 freya022 commented Sep 4, 2025

Alongside with the new additions, instead of having "input names" to match with your handlers @ModalInput, you can now use the native custom ID, note that it must be unique per modal.

Example changes:

@Command
public class SlashFormat extends ApplicationCommand {
    
    private static final String MODAL_NAME = "SlashFormat: formatModal";
-   private static final String CODE_INPUT_NAME = "SlashFormat: formatModal codeInput";
+   private static final String CODE_INPUT_ID = "SlashFormat: formatModal codeInput";
    
    private final Modals modals;

    public SlashFormat(Modals modals) {
        this.modals = modals;
    }

    @JDASlashCommand(name = "format")
    public void onSlashFormat(GuildSlashEvent event) {
        Modal modal = modals.create("Format your code")
                .bindTo(MODAL_NAME)
                .addComponents(
-                       modals.createTextInput(CODE_INPUT_NAME, "Code", TextInputStyle.SHORT)
+                       Label.of(
+                               "Code",
+                               TextInput.create(CODE_INPUT_ID, TextInputStyle.SHORT).build()
+                       )
                )
                .build();
        
        event.replyModal(modal).queue();
    }
    
    @ModalHandler(MODAL_NAME)
-   public void onFormatModal(ModalEvent event, @ModalInput(CODE_INPUT_NAME) String code) {
+   public void onFormatModal(ModalEvent event, @ModalInput(CODE_INPUT_ID) String code) {
        // ...
    }
}

Breaking changes

  • Updated to JDA 6.0.0-rc.4
  • (Kotlin only) name of @ModalInput has been updated to customId
  • Removed custom TextInputBuilder
    • Use TextInput.create (Java) or TextInput(...) { ... } (Kotlin) instead
    • The given custom ID will be used to match against @ModalInput parameters

Changes

  • ActionComponent parameters now accept a broader type, ICustomId

New features

  • Added DSLs:
    • Modals (Modals#create(...) { ... })
    • Labels (Label(...) { ... })
    • Text inputs (TextInput(...) { ... })
    • String select menus (StringSelectMenu(...) { ... })

@freya022 freya022 added type: breaking Contains a backwards incompatible change type: feature V3 labels Sep 4, 2025
@freya022 freya022 force-pushed the feature/modal-labels-and-selects branch from 1899b50 to f9472c2 Compare September 4, 2025 21:21
@freya022 freya022 merged commit f0485d7 into 3.X Sep 5, 2025
2 checks passed
@freya022 freya022 deleted the feature/modal-labels-and-selects branch September 5, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: breaking Contains a backwards incompatible change type: feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants