5050 from .types .components import Component as ComponentPayload
5151 from .types .components import ContainerComponent as ContainerComponentPayload
5252 from .types .components import FileComponent as FileComponentPayload
53+ from .types .components import FileUploadComponent as FileUploadComponentPayload
5354 from .types .components import InputText as InputTextComponentPayload
5455 from .types .components import LabelComponent as LabelComponentPayload
5556 from .types .components import MediaGalleryComponent as MediaGalleryComponentPayload
8182 "Container" ,
8283 "Label" ,
8384 "SelectDefaultValue" ,
85+ "FileUpload" ,
8486)
8587
8688C = TypeVar ("C" , bound = "Component" )
@@ -938,7 +940,6 @@ def url(self, value: str) -> None:
938940
939941 @classmethod
940942 def from_dict (cls , data : UnfurledMediaItemPayload , state = None ) -> UnfurledMediaItem :
941-
942943 r = cls (data .get ("url" ))
943944 r .proxy_url = data .get ("proxy_url" )
944945 r .height = data .get ("height" )
@@ -1347,6 +1348,71 @@ def walk_components(self) -> Iterator[Component]:
13471348 yield from [self .component ]
13481349
13491350
1351+ class FileUpload (Component ):
1352+ """Represents an File Upload component from the Discord Bot UI Kit.
1353+
1354+ This inherits from :class:`Component`.
1355+
1356+ .. note::
1357+
1358+ This class is not useable by end-users; see :class:`discord.ui.FileUpload` instead.
1359+
1360+ .. versionadded:: 2.7
1361+
1362+ Attributes
1363+ ----------
1364+ custom_id: Optional[:class:`str`]
1365+ The custom ID of the file upload field that gets received during an interaction.
1366+ min_values: Optional[:class:`int`]
1367+ The minimum number of files that must be uploaded.
1368+ max_values: Optional[:class:`int`]
1369+ The maximum number of files that can be uploaded.
1370+ required: Optional[:class:`bool`]
1371+ Whether the file upload field is required or not. Defaults to `True`.
1372+ id: Optional[:class:`int`]
1373+ The file upload's ID.
1374+ """
1375+
1376+ __slots__ : tuple [str , ...] = (
1377+ "type" ,
1378+ "custom_id" ,
1379+ "min_values" ,
1380+ "max_values" ,
1381+ "required" ,
1382+ "id" ,
1383+ )
1384+
1385+ __repr_info__ : ClassVar [tuple [str , ...]] = __slots__
1386+ versions : tuple [int , ...] = (1 , 2 )
1387+
1388+ def __init__ (self , data : FileUploadComponentPayload ):
1389+ self .type = ComponentType .file_upload
1390+ self .id : int | None = data .get ("id" )
1391+ self .custom_id = data ["custom_id" ]
1392+ self .min_values : int | None = data .get ("min_values" , None )
1393+ self .max_values : int | None = data .get ("max_values" , None )
1394+ self .required : bool = data .get ("required" , True )
1395+
1396+ def to_dict (self ) -> FileUploadComponentPayload :
1397+ payload = {
1398+ "type" : 19 ,
1399+ "custom_id" : self .custom_id ,
1400+ }
1401+ if self .id is not None :
1402+ payload ["id" ] = self .id
1403+
1404+ if self .min_values is not None :
1405+ payload ["min_values" ] = self .min_values
1406+
1407+ if self .max_values is not None :
1408+ payload ["max_values" ] = self .max_values
1409+
1410+ if not self .required :
1411+ payload ["required" ] = self .required
1412+
1413+ return payload # type: ignore
1414+
1415+
13501416COMPONENT_MAPPINGS = {
13511417 1 : ActionRow ,
13521418 2 : Button ,
@@ -1364,6 +1430,7 @@ def walk_components(self) -> Iterator[Component]:
13641430 14 : Separator ,
13651431 17 : Container ,
13661432 18 : Label ,
1433+ 19 : FileUpload ,
13671434}
13681435
13691436STATE_COMPONENTS = (Section , Container , Thumbnail , MediaGallery , FileComponent )
0 commit comments