Skip to content

Commit 28d9689

Browse files
committed
♻️ Make MediaGallery's items param a capture-all
Signed-off-by: Paillat-dev <[email protected]>
1 parent 3f060c8 commit 28d9689

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

discord/components/media_gallery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class MediaGallery(StateComponentMixin[MediaGalleryComponentPayload], Component[
6262
Parameters
6363
----------
6464
items:
65-
The media this gallery contains.
65+
The media gallery items this gallery contains.
66+
Has to be passed unpacked (e.g. ``*items``).
6667
id:
6768
The component's ID. If not provided by the user, it is set sequentially by
6869
Discord. The ID `0` is treated as if no ID was provided.
@@ -74,15 +75,15 @@ class MediaGallery(StateComponentMixin[MediaGalleryComponentPayload], Component[
7475
versions: tuple[int, ...] = (2,)
7576
type: Literal[ComponentType.media_gallery] = ComponentType.media_gallery # pyright: ignore[reportIncompatibleVariableOverride]
7677

77-
def __init__(self, items: Sequence[MediaGalleryItem], id: int | None = None):
78+
def __init__(self, *items: MediaGalleryItem, id: int | None = None):
7879
self.items: list[MediaGalleryItem] = list(items)
7980
super().__init__(id=id)
8081

8182
@classmethod
8283
@override
8384
def from_payload(cls, payload: MediaGalleryComponentPayload, state: ConnectionState | None = None) -> Self:
8485
items = [MediaGalleryItem.from_payload(d, state=state) for d in payload.get("items", [])]
85-
return cls(items, id=payload.get("id"))
86+
return cls(*items, id=payload.get("id"))
8687

8788
@override
8889
def to_dict(self) -> MediaGalleryComponentPayload:

0 commit comments

Comments
 (0)