Skip to content

Conversation

@AstreaTSS
Copy link
Member

@AstreaTSS AstreaTSS commented Sep 18, 2025

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

This PR adds support for using new features in components related to LabelComponent. This includes LabelComponent itself as well as select menus and file uploads.

To use select menus or file uploads, users must use the new LabelComponent, which also allows adding more flexible labels to questions.

  • Select menus there function how one would expect with the addition of a new required value to control if they are required or not.
  • File uploads requires using the new FileUploadComponent, which is rather self-explanatory in terms of functionality.

To get the values the user selects from these new options, responses in ModalContext has been changed to be dict[str, Any] as opposed to dict[str, str]. This is a breaking change, but it shouldn't be considered a feature that cannot be merged until v6 because:

  • This shouldn't break things for most users. InputText still returns a string, as expected. This only potentially breaks things if one were iterating through responses.
  • This is Discord changing things up, not us.

Changes

  • Added LabelComponent.
  • Adjusted Modal to be able to handle LabelComponent.
  • 💥 Made responses for ModalContext dict[str, Any].
    • See the description for a better explanation.
    • Currently, all of the new methods return lists, so theoretically this could be dict[str, str | list] - Discord plans on adding more components that break this assumption, though.
  • Made ModalContext able to handle LabelComponent and the new options.
  • Added FileUploadComponent.

Related Issues

Test Scenarios

import interactions as ipy

@ipy.slash_command()
async def test(ctx: ipy.SlashContext) -> None:
    modal = ipy.Modal(
        ipy.LabelComponent(
            label="Question 1",
            component=ipy.UserSelectMenu(
                custom_id="user",
                placeholder="Select a user",
                min_values=1,
                max_values=1,
                required=True,
            )
        ),
        ipy.LabelComponent(
            label="Question 2",
            component=ipy.StringSelectMenu(
                ipy.StringSelectOption(label="Option 1", value="option_1"),
                ipy.StringSelectOption(label="Option 2", value="option_2"),
                ipy.StringSelectOption(label="Option 3", value="option_3"),
                custom_id="string",
                placeholder="Select an option",
                min_values=1,
                max_values=1,
                required=True,
            )
        ),
        ipy.LabelComponent(
            label="Question 3",
            component=ipy.FileUploadComponent(
                custom_id="file_upload",
                min_value=1,
                max_value=1,
                required=True,
            )
        ),
        title="Test Modal",
        custom_id="test_modal"
    )
    await ctx.send_modal(modal)


@ipy.modal_callback("test_modal")
async def test_modal_response(ctx: ipy.ModalContext) -> None:
    await ctx.send(
        f"You selected:\n"
        f"User: {ctx.responses['user'][0].mention}\n"
        f"String: {ctx.responses['string'][0]}\n"
        f"File: {ctx.responses['file_upload'][0].id}"
    )

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@silasary silasary changed the base branch from unstable to breaking November 30, 2025 22:39
@AstreaTSS AstreaTSS changed the title feat💥: add support for select menus in modals feat💥: add support for new features in modals Jan 23, 2026
@AstreaTSS
Copy link
Member Author

Retooled this PR to be a catch-all for new modal features, since each phase tends to build upon the last.

AstreaTSS and others added 6 commits January 23, 2026 16:26
Many attempts have been made to make this non-breaking - this means the UX is a little bit off.
Also, as title says, untested.
This requires breaking the assumption that responses always has string keys. That being said, since this is Discord breaking things, not us, this should be fine for a non-breaking release.
Signed-off-by: Astrea <25420078+AstreaTSS@users.noreply.github.com>
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 27.71084% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.51%. Comparing base (871307c) to head (b136375).

Files with missing lines Patch % Lines
interactions/models/internal/context.py 5.40% 35 Missing ⚠️
interactions/models/discord/modal.py 43.24% 21 Missing ⚠️
interactions/models/discord/components.py 0.00% 4 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##           breaking    #1784      +/-   ##
============================================
- Coverage     46.66%   46.51%   -0.15%     
============================================
  Files           149      149              
  Lines         16602    16672      +70     
============================================
+ Hits           7747     7755       +8     
- Misses         8855     8917      +62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Totally forgot Discord did this, oops.
Apparently this has been possible for a while now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants