[docs]classFileUpload(ModalItem):"""Represents a UI File Upload component. .. versionadded:: 2.7 Parameters ---------- custom_id: Optional[:class:`str`] The ID of the input text field that gets received during an interaction. min_values: Optional[:class:`int`] The minimum number of files that must be uploaded. Defaults to 0 and must be between 0 and 10, inclusive. max_values: Optional[:class:`int`] The maximum number of files that can be uploaded. Must be between 1 and 10, inclusive. required: Optional[:class:`bool`] Whether the file upload field is required or not. Defaults to ``True``. id: Optional[:class:`int`] The file upload field's ID. """__item_repr_attributes__:tuple[str,...]=("required","min_values","max_values","custom_id","id",)def__init__(self,*,custom_id:str|None=None,min_values:int|None=None,max_values:int|None=None,required:bool=True,id:int|None=None,):super().__init__()ifmin_valuesand(min_values<0ormin_values>10):raiseValueError("min_values must be between 0 and 10")ifmax_valuesand(max_values<1ormax_values>10):raiseValueError("max_length must be between 1 and 10")ifcustom_idisnotNoneandnotisinstance(custom_id,str):raiseTypeError(f"expected custom_id to be str, not {custom_id.__class__.__name__}")ifnotisinstance(required,bool):raiseTypeError(f"required must be bool not {required.__class__.__name__}")# type: ignorecustom_id=os.urandom(16).hex()ifcustom_idisNoneelsecustom_idself._underlying:FileUploadComponent=FileUploadComponent._raw_construct(type=ComponentType.file_upload,custom_id=custom_id,min_values=min_values,max_values=max_values,required=required,id=id,)self._attachments:list[Attachment]|None=Nonedef__repr__(self)->str:attrs=" ".join(f"{key}={getattr(self,key)!r}"forkeyinself.__item_repr_attributes__)returnf"<{self.__class__.__name__}{attrs}>"@propertydeftype(self)->ComponentType:returnself._underlying.type@propertydefid(self)->int|None:"""The ID of this component. If not provided by the user, it is set sequentially by Discord."""returnself._underlying.id@propertydefcustom_id(self)->str:"""The custom id that gets received during an interaction."""returnself._underlying.custom_id@custom_id.setterdefcustom_id(self,value:str):ifnotisinstance(value,str):raiseTypeError(f"custom_id must be None or str not {value.__class__.__name__}")self._underlying.custom_id=value@propertydefmin_values(self)->int|None:"""The minimum number of files that must be uploaded. Defaults to 0."""returnself._underlying.min_values@min_values.setterdefmin_values(self,value:int|None):ifvalueandnotisinstance(value,int):raiseTypeError(f"min_values must be None or int not {value.__class__.__name__}")# type: ignoreifvalueand(value<0orvalue>10):raiseValueError("min_values must be between 0 and 10")self._underlying.min_values=value@propertydefmax_values(self)->int|None:"""The maximum number of files that can be uploaded."""returnself._underlying.max_values@max_values.setterdefmax_values(self,value:int|None):ifvalueandnotisinstance(value,int):raiseTypeError(f"max_values must be None or int not {value.__class__.__name__}")# type: ignoreifvalueand(value<1orvalue>10):raiseValueError("max_values must be between 1 and 10")self._underlying.max_values=value@propertydefrequired(self)->bool:"""Whether the input file upload is required or not. Defaults to ``True``."""returnself._underlying.required@required.setterdefrequired(self,value:bool):ifnotisinstance(value,bool):raiseTypeError(f"required must be bool not {value.__class__.__name__}")# type: ignoreself._underlying.required=bool(value)@propertydefvalues(self)->list[Attachment]|None:"""The files that were uploaded to the field."""returnself._attachmentsdefto_component_dict(self)->FileUploadComponentPayload:returnself._underlying.to_dict()defrefresh_from_modal(self,interaction:Interaction,data:dict)->None:values=data.get("values",[])self._attachments=[Attachment(state=interaction._state,data=interaction.data["resolved"]["attachments"][attachment_id],)forattachment_idinvalues]