From 7cf9b676c23ec9bd529cd18cf945a602c05bc956 Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:13:56 +0100 Subject: [PATCH 1/8] support file_types on FileUpload and Option --- discord/commands/options.py | 21 ++++++++++++++++- discord/components.py | 14 +++++++++++ discord/enums.py | 20 ++++++++++++++++ discord/types/components.py | 1 + discord/ui/file_upload.py | 46 ++++++++++++++++++++++++++++++++++++- docs/api/enums.rst | 17 ++++++++++++++ 6 files changed, 117 insertions(+), 2 deletions(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index 6567d0c4e7..d21220a593 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -58,7 +58,7 @@ VoiceChannel, ) from ..commands import ApplicationContext, AutocompleteContext -from ..enums import ChannelType +from ..enums import ChannelType, FileType from ..enums import Enum as DiscordEnum from ..enums import SlashCommandOptionType from ..utils import MISSING, basic_autocomplete @@ -195,6 +195,15 @@ class Option: description_localizations: Dict[:class:`str`, :class:`str`] The description localizations for this option. The values of this should be ``"locale": "description"``. See `here `_ for a list of valid locales. + file_types: List[:class:`str`, :class:`FileType`] + The file types allowed for this command. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). + A maximum of 10 file types can be provided, up to 16 characters each. + Only applies to Options with an :attr:`input_type` of :class:`Attachment`. + + .. warning:: + This only checks the file extension - you will still need to validate the file contents yourself. + + .. versionadded:: 2.9 Examples -------- @@ -393,6 +402,14 @@ def __init__( self.description_localizations = kwargs.pop( "description_localizations", MISSING ) + self.file_types: list[FileType | str] = kwargs.pop("file_types", []) + if len(self.file_types) > 10: + raise ValueError("file_types must be between 0 and 10 in length") + for f in self.file_types: + if not isinstance(f, (str, FileType)): + raise TypeError("items in file_types must be of type str or FileType") + if len(str(f)) > 16: + raise ValueError("items in file_types must be a maximum of 16 characters in length") if input_type is None: raise TypeError("input_type cannot be NoneType.") @@ -453,6 +470,8 @@ def to_dict(self) -> dict: as_dict["min_length"] = self.min_length if self.max_length is not None: as_dict["max_length"] = self.max_length + if self.file_types: + as_dict["file_types"] = [str(f) for f in self.file_types] return as_dict diff --git a/discord/components.py b/discord/components.py index 5749e4ad74..5e3877a099 100644 --- a/discord/components.py +++ b/discord/components.py @@ -36,6 +36,7 @@ InputTextStyle, SelectDefaultValueType, SeparatorSpacingSize, + FileType, try_enum, ) from .flags import AttachmentFlags @@ -1386,6 +1387,14 @@ class FileUpload(Component): The maximum number of files that can be uploaded. required: Optional[:class:`bool`] Whether the file upload field is required or not. Defaults to `True`. + file_types: List[:class:`str`, :class:`FileType`] + The file types allowed in this upload. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). + A maximum of 10 file types can be provided, up to 16 characters each. + + .. warning:: + This only checks the file extension - you will still need to validate the file contents yourself. + + .. versionadded:: 2.9 id: Optional[:class:`int`] The file upload's ID. """ @@ -1396,6 +1405,7 @@ class FileUpload(Component): "min_values", "max_values", "required", + "file_types", "id", ) @@ -1409,6 +1419,7 @@ def __init__(self, data: FileUploadComponentPayload): self.min_values: int | None = data.get("min_values", None) self.max_values: int | None = data.get("max_values", None) self.required: bool = data.get("required", True) + self.file_types: list[str | FileType] = data.get("file_types", []) def to_dict(self) -> FileUploadComponentPayload: payload = { @@ -1426,6 +1437,9 @@ def to_dict(self) -> FileUploadComponentPayload: if not self.required: payload["required"] = self.required + + if self.file_types: + payload["file_types"] = [str(f) for f in self.file_types] return payload # type: ignore diff --git a/discord/enums.py b/discord/enums.py index 5011a338c2..63b788de5d 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -88,6 +88,7 @@ "SelectDefaultValueType", "ApplicationEventWebhookStatus", "InviteTargetUsersJobStatusCode", + "FileUpload", ) @@ -1212,6 +1213,25 @@ class InviteTargetUsersJobStatusCode(Enum): failed = 3 +class FileType(Enum): + """Represents the allowed file types in an attachment option or component. The types are subject to change based on what is supported on Discord clients. + + .. versionadded:: 2.9 + + Attributes + ---------- + image: :class:`str` + Allow image files. This includes ``.png``, ``.gif``, ``.jpg``, ``.jpeg``, ``.jfif``, ``.webp``, and ``.avif``. + video: :class:`str` + Allow video files. This includes ``.mp4``, ``.mov``, ``.qt``, and ``.webm``. + audio: :class:`str` + Allow audio files. This includes ``.mp3``, ``.m4a``, ``.wav``, ``.ogg``, ``.opus``, and ``.flac``. + """ + image = "image" + video = "video" + audio = "audio" + + T = TypeVar("T") diff --git a/discord/types/components.py b/discord/types/components.py index af567b6566..c8dd29779d 100644 --- a/discord/types/components.py +++ b/discord/types/components.py @@ -174,6 +174,7 @@ class FileUploadComponent(BaseComponent): max_values: NotRequired[int] min_values: NotRequired[int] required: NotRequired[bool] + file_types: NotRequired[list[str]] class RadioGroupOption(TypedDict): diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index 784b8f6733..1c042cf515 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -28,7 +28,7 @@ from typing import TYPE_CHECKING from ..components import FileUpload as FileUploadComponent -from ..enums import ComponentType +from ..enums import ComponentType, FileType from ..message import Attachment from .item import ModalItem @@ -58,6 +58,14 @@ class FileUpload(ModalItem): Whether the file upload field is required or not. Defaults to ``True``. id: Optional[:class:`int`] The file upload field's ID. + file_types: List[:class:`str`, :class:`FileType`] + The file types allowed in this file upload. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). + A maximum of 10 file types can be provided, up to 16 characters each. + + .. warning:: + This only checks the file extension - you will still need to validate the file contents yourself. + + .. versionadded:: 2.9 """ __item_repr_attributes__: tuple[str, ...] = ( @@ -75,6 +83,7 @@ def __init__( min_values: int | None = None, max_values: int | None = None, required: bool = True, + file_types: list[str | FileType] | None = None, id: int | None = None, ): super().__init__() @@ -88,6 +97,13 @@ def __init__( ) if not isinstance(required, bool): raise TypeError(f"required must be bool not {required.__class__.__name__}") # type: ignore + if len(file_types) > 10: + raise ValueError("file_types must be between 0 and 10 in length") + for f in file_types: + if not isinstance(f, (str, FileType)): + raise TypeError("items in file_types must be of type str or FileType") + if len(str(f)) > 16: + raise ValueError("items in file_types must be a maximum of 16 characters in length") custom_id = os.urandom(16).hex() if custom_id is None else custom_id self._attachments: list[Attachment] | None = None @@ -96,6 +112,7 @@ def __init__( min_values=min_values, max_values=max_values, required=required, + file_types=file_types, id=id, ) @@ -105,6 +122,7 @@ def _generate_underlying( min_values: int | None = None, max_values: int | None = None, required: bool | None = None, + file_types: list[str | FileType] | None = None, id: int | None = None, ) -> FileUploadComponent: super()._generate_underlying(FileUploadComponent) @@ -114,6 +132,7 @@ def _generate_underlying( min_values=min_values if min_values is not None else self.min_values, max_values=max_values if max_values is not None else self.max_values, required=required if required is not None else self.required, + file_types=file_types if file_types else [], id=id or self.id, ) @@ -167,6 +186,30 @@ def required(self, value: bool): raise TypeError(f"required must be bool not {value.__class__.__name__}") # type: ignore self.underlying.required = bool(value) + @property + def file_types(self) -> list[str | FileType]: + """The file types allowed in this file upload. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). + A maximum of 10 file types can be provided, up to 16 characters each. + + .. warning:: + This only checks the file extension - you will still need to validate the file contents yourself. + + .. versionadded:: 2.9 + """ + return self.underlying.file_types + + @file_types.setter + def file_types(self, value: list[str | FileType] | None): + if file_types: + if len(self.file_types) > 10: + raise ValueError("file_types must be between 0 and 10 in length") + for f in self.file_types: + if not isinstance(f, (str, FileType)): + raise TypeError("items in file_types must be of type str or FileType") + if len(str(f)) > 16: + raise ValueError("items in file_types must be a maximum of 16 characters in length") + self.underlying.file_types = file_types or [] + @property def values(self) -> list[Attachment] | None: """The files that were uploaded to the field. This will be ``None`` if the file upload has not been submitted via a modal yet.""" @@ -195,5 +238,6 @@ def from_component( min_values=component.min_values, max_values=component.max_values, required=component.required, + file_types=component.file_types, id=component.id, ) diff --git a/docs/api/enums.rst b/docs/api/enums.rst index efa16a4a5e..ee051ca989 100644 --- a/docs/api/enums.rst +++ b/docs/api/enums.rst @@ -2702,3 +2702,20 @@ of :class:`enum.Enum`. .. attribute:: read_only Represents the team read only role. + +.. class:: FileType + Represents the allowed file types in an attachment option or component. The types are subject to change based on what is supported on Discord clients. + + .. versionadded:: 2.9 + + .. attribute:: image + + Allow image files. This includes ``.png``, ``.gif``, ``.jpg``, ``.jpeg``, ``.jfif``, ``.webp``, and ``.avif``. + + .. attribute:: video + + Allow video files. This includes ``.mp4``, ``.mov``, ``.qt``, and ``.webm``. + + .. attribute:: audio + + Allow audio files. This includes ``.mp3``, ``.m4a``, ``.wav``, ``.ogg``, ``.opus``, and ``.flac``. From c86a40e79a1ac455d04397778d4a97ed46aa716f Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:23:40 +0100 Subject: [PATCH 2/8] enum reconvert --- discord/components.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discord/components.py b/discord/components.py index 5e3877a099..3b1989f60a 100644 --- a/discord/components.py +++ b/discord/components.py @@ -1419,7 +1419,9 @@ def __init__(self, data: FileUploadComponentPayload): self.min_values: int | None = data.get("min_values", None) self.max_values: int | None = data.get("max_values", None) self.required: bool = data.get("required", True) - self.file_types: list[str | FileType] = data.get("file_types", []) + self.file_types: list[str | FileType] = [] + for f in data.get("file_types", []): + self.file_types.append(f) if f not in FileType.__members__ else try_enum(FileType, f) def to_dict(self) -> FileUploadComponentPayload: payload = { From f35b0a269804cdf735239acaa2e9702a371bd941 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 04:24:31 +0000 Subject: [PATCH 3/8] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/commands/options.py | 8 +++++--- discord/components.py | 10 +++++++--- discord/enums.py | 1 + discord/ui/file_upload.py | 12 +++++++++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index d21220a593..70f3864624 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -58,9 +58,9 @@ VoiceChannel, ) from ..commands import ApplicationContext, AutocompleteContext -from ..enums import ChannelType, FileType +from ..enums import ChannelType from ..enums import Enum as DiscordEnum -from ..enums import SlashCommandOptionType +from ..enums import FileType, SlashCommandOptionType from ..utils import MISSING, basic_autocomplete if TYPE_CHECKING: @@ -409,7 +409,9 @@ def __init__( if not isinstance(f, (str, FileType)): raise TypeError("items in file_types must be of type str or FileType") if len(str(f)) > 16: - raise ValueError("items in file_types must be a maximum of 16 characters in length") + raise ValueError( + "items in file_types must be a maximum of 16 characters in length" + ) if input_type is None: raise TypeError("input_type cannot be NoneType.") diff --git a/discord/components.py b/discord/components.py index 3b1989f60a..09b77b2a02 100644 --- a/discord/components.py +++ b/discord/components.py @@ -33,10 +33,10 @@ ButtonStyle, ChannelType, ComponentType, + FileType, InputTextStyle, SelectDefaultValueType, SeparatorSpacingSize, - FileType, try_enum, ) from .flags import AttachmentFlags @@ -1421,7 +1421,11 @@ def __init__(self, data: FileUploadComponentPayload): self.required: bool = data.get("required", True) self.file_types: list[str | FileType] = [] for f in data.get("file_types", []): - self.file_types.append(f) if f not in FileType.__members__ else try_enum(FileType, f) + ( + self.file_types.append(f) + if f not in FileType.__members__ + else try_enum(FileType, f) + ) def to_dict(self) -> FileUploadComponentPayload: payload = { @@ -1439,7 +1443,7 @@ def to_dict(self) -> FileUploadComponentPayload: if not self.required: payload["required"] = self.required - + if self.file_types: payload["file_types"] = [str(f) for f in self.file_types] diff --git a/discord/enums.py b/discord/enums.py index 63b788de5d..e918ce54c5 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -1227,6 +1227,7 @@ class FileType(Enum): audio: :class:`str` Allow audio files. This includes ``.mp3``, ``.m4a``, ``.wav``, ``.ogg``, ``.opus``, and ``.flac``. """ + image = "image" video = "video" audio = "audio" diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index 1c042cf515..5e7b9144e0 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -103,7 +103,9 @@ def __init__( if not isinstance(f, (str, FileType)): raise TypeError("items in file_types must be of type str or FileType") if len(str(f)) > 16: - raise ValueError("items in file_types must be a maximum of 16 characters in length") + raise ValueError( + "items in file_types must be a maximum of 16 characters in length" + ) custom_id = os.urandom(16).hex() if custom_id is None else custom_id self._attachments: list[Attachment] | None = None @@ -205,9 +207,13 @@ def file_types(self, value: list[str | FileType] | None): raise ValueError("file_types must be between 0 and 10 in length") for f in self.file_types: if not isinstance(f, (str, FileType)): - raise TypeError("items in file_types must be of type str or FileType") + raise TypeError( + "items in file_types must be of type str or FileType" + ) if len(str(f)) > 16: - raise ValueError("items in file_types must be a maximum of 16 characters in length") + raise ValueError( + "items in file_types must be a maximum of 16 characters in length" + ) self.underlying.file_types = file_types or [] @property From 00b0211d2827c801433654db83212d9f626fd513 Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:27:55 +0100 Subject: [PATCH 4/8] repr --- discord/ui/file_upload.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index 5e7b9144e0..4c59f50ccb 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -73,6 +73,7 @@ class FileUpload(ModalItem): "min_values", "max_values", "custom_id", + "file_types", "id", ) From edac61c36b4b2ac18df162350ce6dc1227f37ee4 Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:31:01 +0100 Subject: [PATCH 5/8] set --- discord/enums.py | 2 +- discord/ui/file_upload.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index e918ce54c5..c45c7690cd 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -88,7 +88,7 @@ "SelectDefaultValueType", "ApplicationEventWebhookStatus", "InviteTargetUsersJobStatusCode", - "FileUpload", + "FileType", ) diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index 4c59f50ccb..f4572a644b 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -204,9 +204,9 @@ def file_types(self) -> list[str | FileType]: @file_types.setter def file_types(self, value: list[str | FileType] | None): if file_types: - if len(self.file_types) > 10: + if len(file_types) > 10: raise ValueError("file_types must be between 0 and 10 in length") - for f in self.file_types: + for f in file_types: if not isinstance(f, (str, FileType)): raise TypeError( "items in file_types must be of type str or FileType" From 6dc69b4eaa612f2d8471b4cddf0d2855c19fef53 Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:33:01 +0100 Subject: [PATCH 6/8] value --- discord/ui/file_upload.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index f4572a644b..83a5f0a67f 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -203,10 +203,10 @@ def file_types(self) -> list[str | FileType]: @file_types.setter def file_types(self, value: list[str | FileType] | None): - if file_types: - if len(file_types) > 10: + if value: + if len(value) > 10: raise ValueError("file_types must be between 0 and 10 in length") - for f in file_types: + for f in value: if not isinstance(f, (str, FileType)): raise TypeError( "items in file_types must be of type str or FileType" @@ -215,7 +215,7 @@ def file_types(self, value: list[str | FileType] | None): raise ValueError( "items in file_types must be a maximum of 16 characters in length" ) - self.underlying.file_types = file_types or [] + self.underlying.file_types = value or [] @property def values(self) -> list[Attachment] | None: From 868fdf36a1b7a608b6f011d2f0cb0fcd2ca26575 Mon Sep 17 00:00:00 2001 From: Nelo <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 23 Jun 2026 06:25:17 +0100 Subject: [PATCH 7/8] validate file_types --- discord/commands/options.py | 25 ++++++++++++++----------- discord/ui/file_upload.py | 23 ++++++++++++++--------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index 70f3864624..cfa557876a 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -196,7 +196,7 @@ class Option: The description localizations for this option. The values of this should be ``"locale": "description"``. See `here `_ for a list of valid locales. file_types: List[:class:`str`, :class:`FileType`] - The file types allowed for this command. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). + The file types allowed for this option. Supports a mix of :class:`FileType` and dot-prefixed extensions (e.g. ``".pdf"``). A maximum of 10 file types can be provided, up to 16 characters each. Only applies to Options with an :attr:`input_type` of :class:`Attachment`. @@ -402,16 +402,19 @@ def __init__( self.description_localizations = kwargs.pop( "description_localizations", MISSING ) - self.file_types: list[FileType | str] = kwargs.pop("file_types", []) - if len(self.file_types) > 10: - raise ValueError("file_types must be between 0 and 10 in length") - for f in self.file_types: - if not isinstance(f, (str, FileType)): - raise TypeError("items in file_types must be of type str or FileType") - if len(str(f)) > 16: - raise ValueError( - "items in file_types must be a maximum of 16 characters in length" - ) + self.file_types: list[FileType | str] = kwargs.pop("file_types", []) or [] + if self.file_types: + if not isinstance(self.file_types, list): + raise TypeError(f"file_types must be a list, not {self.file_types.__class__.__name__}") + if len(self.file_types) > 10: + raise ValueError("file_types must be between 0 and 10 in length") + for f in self.file_types: + if not isinstance(f, (str, FileType)): + raise TypeError("items in file_types must be of type str or FileType") + if len(str(f)) > 16: + raise ValueError( + "items in file_types must be a maximum of 16 characters in length" + ) if input_type is None: raise TypeError("input_type cannot be NoneType.") diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index 83a5f0a67f..ceff1cfa22 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -98,15 +98,18 @@ def __init__( ) if not isinstance(required, bool): raise TypeError(f"required must be bool not {required.__class__.__name__}") # type: ignore - if len(file_types) > 10: - raise ValueError("file_types must be between 0 and 10 in length") - for f in file_types: - if not isinstance(f, (str, FileType)): - raise TypeError("items in file_types must be of type str or FileType") - if len(str(f)) > 16: - raise ValueError( - "items in file_types must be a maximum of 16 characters in length" - ) + if file_types is not None: + if not isinstance(file_types, list): + raise TypeError(f"file_types must be a list, not {file_types.__class__.__name__}") + if len(file_types) > 10: + raise ValueError("file_types must be between 0 and 10 in length") + for f in file_types: + if not isinstance(f, (str, FileType)): + raise TypeError("items in file_types must be of type str or FileType") + if len(str(f)) > 16: + raise ValueError( + "items in file_types must be a maximum of 16 characters in length" + ) custom_id = os.urandom(16).hex() if custom_id is None else custom_id self._attachments: list[Attachment] | None = None @@ -204,6 +207,8 @@ def file_types(self) -> list[str | FileType]: @file_types.setter def file_types(self, value: list[str | FileType] | None): if value: + if not isinstance(value, list): + raise TypeError(f"file_types must be a list, not {value.__class__.__name__}") if len(value) > 10: raise ValueError("file_types must be between 0 and 10 in length") for f in value: From 08157600d19ea6cc87a894b1a743b84d985aa19e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jun 2026 05:25:46 +0000 Subject: [PATCH 8/8] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/commands/options.py | 8 ++++++-- discord/ui/file_upload.py | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index cfa557876a..8359a2dde5 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -405,12 +405,16 @@ def __init__( self.file_types: list[FileType | str] = kwargs.pop("file_types", []) or [] if self.file_types: if not isinstance(self.file_types, list): - raise TypeError(f"file_types must be a list, not {self.file_types.__class__.__name__}") + raise TypeError( + f"file_types must be a list, not {self.file_types.__class__.__name__}" + ) if len(self.file_types) > 10: raise ValueError("file_types must be between 0 and 10 in length") for f in self.file_types: if not isinstance(f, (str, FileType)): - raise TypeError("items in file_types must be of type str or FileType") + raise TypeError( + "items in file_types must be of type str or FileType" + ) if len(str(f)) > 16: raise ValueError( "items in file_types must be a maximum of 16 characters in length" diff --git a/discord/ui/file_upload.py b/discord/ui/file_upload.py index ceff1cfa22..04b586028c 100644 --- a/discord/ui/file_upload.py +++ b/discord/ui/file_upload.py @@ -100,12 +100,16 @@ def __init__( raise TypeError(f"required must be bool not {required.__class__.__name__}") # type: ignore if file_types is not None: if not isinstance(file_types, list): - raise TypeError(f"file_types must be a list, not {file_types.__class__.__name__}") + raise TypeError( + f"file_types must be a list, not {file_types.__class__.__name__}" + ) if len(file_types) > 10: raise ValueError("file_types must be between 0 and 10 in length") for f in file_types: if not isinstance(f, (str, FileType)): - raise TypeError("items in file_types must be of type str or FileType") + raise TypeError( + "items in file_types must be of type str or FileType" + ) if len(str(f)) > 16: raise ValueError( "items in file_types must be a maximum of 16 characters in length" @@ -208,7 +212,9 @@ def file_types(self) -> list[str | FileType]: def file_types(self, value: list[str | FileType] | None): if value: if not isinstance(value, list): - raise TypeError(f"file_types must be a list, not {value.__class__.__name__}") + raise TypeError( + f"file_types must be a list, not {value.__class__.__name__}" + ) if len(value) > 10: raise ValueError("file_types must be between 0 and 10 in length") for f in value: