Skip to content

Conversation

freya022
Copy link
Contributor

@freya022 freya022 commented Sep 18, 2025

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: Tests

Closes Issue: NaN

Description

This adds the ability for users to submit files in modals.

Note: The feature will be staff-locked for a while, but you can still submit feedback.

Discord docs: discord/discord-api-docs#7887

Usage

Sending

Modal modal = Modal.create("add-http-cats", "Add an HTTP cat")
        .addComponents(
                Label.of(
                        "HTTP Status Code",
                        TextInput.create("http-status-code", TextInputStyle.SHORT)
                                .setMaxLength(3)
                                .build()
                ),
                Label.of(
                        "File",
                        AttachmentUpload.create("cat-img")
                                .setMaxValues(10)
                                .build()
                )
        )
        .build();

Receiving

Where event is a ModalInteractionEvent:

String statusCode = event.getValue("http-status-code").getAsString();
List<Message.Attachment> cats = event.getValue("cat-img").getAsAttachmentList();

@freya022 freya022 force-pushed the feature/modal-file-upload branch from 02761a0 to 6c63173 Compare September 18, 2025 13:40
@freya022 freya022 force-pushed the feature/modal-file-upload branch from 6c63173 to ad5fc4f Compare September 18, 2025 14:21
@fa1c0nx
Copy link

fa1c0nx commented Sep 18, 2025

Haha we were just discussing this and you came out of no where with a solution 🔥

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.

4 participants