66from ..components import FileUpload as FileUploadComponent
77from ..enums import ComponentType
88from ..message import Attachment
9+ from .item import ModalItem
910
1011__all__ = ("FileUpload" ,)
1112
1415 from ..types .components import FileUploadComponent as FileUploadComponentPayload
1516
1617
17- class FileUpload :
18+ class FileUpload ( ModalItem ) :
1819 """Represents a UI File Upload component.
1920
2021 .. versionadded:: 2.7
2122
2223 Parameters
2324 ----------
24- label: :class:`str`
25- The label for this component
26- Must be 45 characters or fewer.
2725 custom_id: Optional[:class:`str`]
2826 The ID of the input text field that gets received during an interaction.
29- description: Optional[:class:`str`]
30- The description for the file upload field.
31- Must be 100 characters or fewer.
3227 min_values: Optional[:class:`int`]
3328 The minimum number of files that must be uploaded.
3429 Defaults to 0 and must be between 0 and 10, inclusive.
@@ -37,41 +32,28 @@ class FileUpload:
3732 Must be between 1 and 10, inclusive.
3833 required: Optional[:class:`bool`]
3934 Whether the file upload field is required or not. Defaults to ``True``.
40- row: Optional[:class:`int`]
41- The relative row this file upload field belongs to. A modal dialog can only have 5
42- rows. By default, items are arranged automatically into those 5 rows. If you'd
43- like to control the relative positioning of the row then passing an index is advised.
44- For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
45- ordering. The row number must be between 0 and 4 (i.e. zero indexed).
35+ id: Optional[:class:`int`]
36+ The file upload field's ID.
4637 """
4738
4839 __item_repr_attributes__ : tuple [str , ...] = (
49- "label" ,
5040 "required" ,
5141 "min_values" ,
5242 "max_values" ,
5343 "custom_id" ,
5444 "id" ,
55- "description" ,
5645 )
5746
5847 def __init__ (
5948 self ,
6049 * ,
61- label : str ,
6250 custom_id : str | None = None ,
6351 min_values : int | None = None ,
6452 max_values : int | None = None ,
6553 required : bool = True ,
66- row : int | None = None ,
6754 id : int | None = None ,
68- description : str | None = None ,
6955 ):
7056 super ().__init__ ()
71- if len (str (label )) > 45 :
72- raise ValueError ("label must be 45 characters or fewer" )
73- if description and len (description ) > 100 :
74- raise ValueError ("description must be 100 characters or fewer" )
7557 if min_values and (min_values < 0 or min_values > 10 ):
7658 raise ValueError ("min_values must be between 0 and 10" )
7759 if max_values and (max_values < 1 or max_values > 10 ):
@@ -83,8 +65,6 @@ def __init__(
8365 if not isinstance (required , bool ):
8466 raise TypeError (f"required must be bool not { required .__class__ .__name__ } " ) # type: ignore
8567 custom_id = os .urandom (16 ).hex () if custom_id is None else custom_id
86- self .label : str = str (label )
87- self .description : str | None = description
8868
8969 self ._underlying : FileUploadComponent = FileUploadComponent ._raw_construct (
9070 type = ComponentType .file_upload ,
@@ -168,10 +148,6 @@ def values(self) -> list[Attachment] | None:
168148 """The files that were uploaded to the field."""
169149 return self ._attachments
170150
171- @property
172- def width (self ) -> int :
173- return 5
174-
175151 def to_component_dict (self ) -> FileUploadComponentPayload :
176152 return self ._underlying .to_dict ()
177153
@@ -184,7 +160,3 @@ def refresh_from_modal(self, interaction: Interaction, data: dict) -> None:
184160 )
185161 for attachment_id in values
186162 ]
187-
188- @staticmethod
189- def uses_label () -> bool :
190- return True
0 commit comments