-
Notifications
You must be signed in to change notification settings - Fork 144
feat(components): add FileUpload
component
#1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
c480fca
b416441
e3bc7ce
203f96a
4651a46
7f7402f
1fd8821
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a :class:`ui.FileUpload` component for modals. This allows you to receive up to 10 files from users in a modal. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ | |
|
||
from typing import List, Literal, Optional, TypedDict, Union | ||
|
||
from typing_extensions import NotRequired, Required, TypeAlias | ||
from typing_extensions import NotRequired, ReadOnly, Required, TypeAlias | ||
|
||
from .channel import ChannelType | ||
from .emoji import PartialEmoji | ||
from .snowflake import Snowflake | ||
|
||
ComponentType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18] | ||
ComponentType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 19] | ||
ButtonStyle = Literal[1, 2, 3, 4, 5, 6] | ||
TextInputStyle = Literal[1, 2] | ||
SeparatorSpacing = Literal[1, 2] | ||
|
@@ -34,6 +34,7 @@ | |
"SeparatorComponent", | ||
"ContainerComponent", | ||
"LabelComponent", | ||
"FileUploadComponent", | ||
] | ||
|
||
ActionRowChildComponent = Union[ | ||
|
@@ -45,6 +46,7 @@ | |
LabelChildComponent = Union[ | ||
"TextInput", | ||
"AnySelectMenu", | ||
"FileUploadComponent", | ||
] | ||
|
||
# valid message component types (v1/v2) | ||
|
@@ -72,7 +74,7 @@ | |
|
||
|
||
class _BaseComponent(TypedDict): | ||
# type: ComponentType # FIXME: current version of pyright only supports PEP 705 experimentally, this can be re-enabled in 1.1.353+ | ||
type: ReadOnly[ComponentType] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope. Please submit a separate change request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't worth a separate PR, as it doesn't really fix anything. I can just remove it from this one, if you'd like. |
||
id: int # note: technically optional when sending, we just default to 0 for simplicity, which is equivalent (https://discord.com/developers/docs/components/reference#anatomy-of-a-component) | ||
|
||
|
||
|
@@ -185,6 +187,14 @@ class LabelComponent(_BaseComponent): | |
component: LabelChildComponent | ||
|
||
|
||
class FileUploadComponent(_BaseComponent): | ||
type: Literal[19] | ||
custom_id: str | ||
min_values: NotRequired[int] | ||
max_values: NotRequired[int] | ||
required: NotRequired[bool] | ||
|
||
|
||
# components v2 | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.