feat: FileUpload in Modal#2938
Merged
Merged
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/2938/head:pr-2938
git checkout pr-2938This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2938/head |
Member
Author
|
my test code for those who are able to test: import discord
from discord import Interaction
class Modal(discord.ui.Modal):
def __init__(self):
super().__init__(title="Test Modal")
self.add_item(discord.ui.InputText(required=False, label="Test", row=1))
self.add_item(discord.ui.FileUpload(label="Upload Files", required=False, min_values=2, max_values=5, row=2))
self.add_item(discord.ui.InputText(required=False, label="Test"))
async def callback(self, interaction: Interaction):
await interaction.response.defer(ephemeral=True, invisible=False)
# reupload all attachments as files
attachments = self.children[1].values
print(attachments)
files = [await attachment.to_file() for attachment in attachments]
await interaction.followup.send("Here are your files:", files=files, ephemeral=True)
bot = discord.Bot()
@bot.command(integration_types={discord.IntegrationType.user_install})
async def command(ctx):
await ctx.send_modal(Modal())
@bot.listen()
async def on_interaction(inter):
print(inter.data)
bot.run("TOKEN") |
Contributor
I will take a look tonight then |
Soheab
requested changes
Oct 8, 2025
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Signed-off-by: plun1331 <[email protected]>
Co-authored-by: Soheab <[email protected]> Signed-off-by: plun1331 <[email protected]>
Signed-off-by: plun1331 <[email protected]>
Paillat-dev
previously approved these changes
Oct 11, 2025
Soheab
requested changes
Oct 11, 2025
Signed-off-by: Soheab <[email protected]>
Soheab
approved these changes
Oct 11, 2025
Contributor
There was a problem hiding this comment.
Tested.
Code
import discord
client = discord.Bot()
class UploadMe(discord.ui.Modal):
def __init__(self) -> None:
super().__init__(title="Upload a file")
self.file = discord.ui.FileUpload(
label="Upload a file",
)
self.add_item(self.file)
async def callback(self, interaction: discord.Interaction) -> None:
files = self.file.values or []
print(files)
await interaction.response.send_message(f"Uploaded {len(files)} files!")
@client.slash_command(
contexts=[
discord.InteractionContextType.guild,
],
integration_types=[
discord.IntegrationType.user_install,
],
)
async def upload(interaction: discord.Interaction) -> None:
"""Upload a file"""
n = UploadMe()
print(n.to_dict())
await interaction.response.send_modal(n)
client.run("...")
Paillat-dev
dismissed
Lumabots’s stale review
October 11, 2025 13:28
type: ignore are good like that for now.
Paillat-dev
approved these changes
Oct 11, 2025
plun1331
enabled auto-merge (squash)
October 11, 2025 20:30
Member
Author
|
@Lulalaby when able please :3 |
Lulalaby
approved these changes
Oct 15, 2025
Lulalaby
disabled auto-merge
October 15, 2025 19:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
first
also bug fixes
currently locked to private beta, cannot be used publicly yet
this basically is just a duplicate of InputText with inspiration taken from Select for implementation
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.