diff --git a/discord/components.py b/discord/components.py index 4321d79dc..ac4ff987e 100644 --- a/discord/components.py +++ b/discord/components.py @@ -719,7 +719,7 @@ class SectionComponent(Component): ---------- components: List[Union[:class:`TextDisplay`, :class:`Button`]] The components on this section. - accessory: Optional[:class:`Component`] + accessory: :class:`Component` The section accessory. """ @@ -762,6 +762,8 @@ class ThumbnailComponent(Component): The user constructible and usable type to create a thumbnail is :class:`discord.ui.Thumbnail` not this one. + .. versionadded:: 2.6 + Attributes ---------- media: :class:`UnfurledMediaItem` @@ -772,7 +774,13 @@ class ThumbnailComponent(Component): Whether this thumbnail is flagged as a spoiler. """ - __slots__ = () + __slots__ = ( + 'media', + 'spoiler', + 'description', + ) + + __repr_info__ = __slots__ def __init__( self, @@ -801,6 +809,11 @@ class TextDisplay(Component): This inherits from :class:`Component`. + .. note:: + + The user constructible and usable type to create a text display is + :class:`discord.ui.TextDisplay` not this one. + .. versionadded:: 2.6 Attributes @@ -809,6 +822,10 @@ class TextDisplay(Component): The content that this display shows. """ + __slots__ = ('content',) + + __repr_info__ = __slots__ + def __init__(self, data: TextComponentPayload) -> None: self.content: str = data['content'] @@ -826,6 +843,8 @@ class TextDisplay(Component): class UnfurledMediaItem(AssetMixin): """Represents an unfurled media item. + .. versionadded:: 2.6 + Parameters ---------- url: :class:`str` @@ -896,6 +915,9 @@ class UnfurledMediaItem(AssetMixin): self.loading_state = try_enum(MediaItemLoadingState, data['loading_state']) self._state = state + def __repr__(self) -> str: + return f'' + def to_dict(self): return { 'url': self.url, @@ -905,6 +927,8 @@ class UnfurledMediaItem(AssetMixin): class MediaGalleryItem: """Represents a :class:`MediaGalleryComponent` media item. + .. versionadded:: 2.6 + Parameters ---------- media: Union[:class:`str`, :class:`UnfurledMediaItem`] @@ -936,6 +960,9 @@ class MediaGalleryItem: self.spoiler: bool = spoiler self._state: Optional[ConnectionState] = None + def __repr__(self) -> str: + return f'' + @classmethod def _from_data(cls, data: MediaGalleryItemPayload, state: Optional[ConnectionState]) -> MediaGalleryItem: media = data['media'] @@ -968,13 +995,22 @@ class MediaGalleryComponent(Component): This inherits from :class:`Component`. + .. note:: + + The user constructible and usable type for creating a media gallery is + :class:`discord.ui.MediaGallery` not this one. + + .. versionadded:: 2.6 + Attributes ---------- items: List[:class:`MediaGalleryItem`] The items this gallery has. """ - __slots__ = ('items', 'id') + __slots__ = ('items',) + + __repr_info__ = __slots__ def __init__(self, data: MediaGalleryComponentPayload, state: Optional[ConnectionState]) -> None: self.items: List[MediaGalleryItem] = MediaGalleryItem._from_gallery(data['items'], state) @@ -995,6 +1031,13 @@ class FileComponent(Component): This inherits from :class:`Component`. + .. note:: + + The user constructible and usable type for create a file component is + :class:`discord.ui.File` not this one. + + .. versionadded:: 2.6 + Attributes ---------- media: :class:`UnfurledMediaItem` @@ -1008,6 +1051,8 @@ class FileComponent(Component): 'spoiler', ) + __repr_info__ = __slots__ + def __init__(self, data: FileComponentPayload, state: Optional[ConnectionState]) -> None: self.media: UnfurledMediaItem = UnfurledMediaItem._from_data(data['file'], state) self.spoiler: bool = data.get('spoiler', False) @@ -1029,6 +1074,13 @@ class SeparatorComponent(Component): This inherits from :class:`Component`. + .. note:: + + The user constructible and usable type for creating a separator is + :class:`discord.ui.Separator` not this one. + + .. versionadded:: 2.6 + Attributes ---------- spacing: :class:`SeparatorSize` @@ -1042,6 +1094,8 @@ class SeparatorComponent(Component): 'visible', ) + __repr_info__ = __slots__ + def __init__( self, data: SeparatorComponentPayload, @@ -1066,6 +1120,13 @@ class Container(Component): This inherits from :class:`Component`. + .. note:: + + The user constructible and usable type for creating a container is + :class:`discord.ui.Container` not this one. + + .. versionadded:: 2.6 + Attributes ---------- children: :class:`Component`