1111from .action_row import ActionRow
1212from .button import Button
1313from .file import File
14- from .item import Item , ItemCallbackType
14+ from .item import ViewItem , ItemCallbackType
1515from .media_gallery import MediaGallery
1616from .section import Section
1717from .select import Select
3232V = TypeVar ("V" , bound = "DesignerView" , covariant = True )
3333
3434
35- class Container (Item [V ]):
35+ class Container (ViewItem [V ]):
3636 """Represents a UI Container.
3737
3838 The current items supported are as follows:
@@ -48,7 +48,7 @@ class Container(Item[V]):
4848
4949 Parameters
5050 ----------
51- *items: :class:`Item `
51+ *items: :class:`ViewItem `
5252 The initial items in this container.
5353 colour: Union[:class:`Colour`, :class:`int`]
5454 The accent colour of the container. Aliased to ``color`` as well.
@@ -75,15 +75,15 @@ def __init_subclass__(cls) -> None:
7575
7676 def __init__ (
7777 self ,
78- * items : Item ,
78+ * items : ViewItem ,
7979 colour : int | Colour | None = None ,
8080 color : int | Colour | None = None ,
8181 spoiler : bool = False ,
8282 id : int | None = None ,
8383 ):
8484 super ().__init__ ()
8585
86- self .items : list [Item ] = []
86+ self .items : list [ViewItem ] = []
8787
8888 self ._underlying = ContainerComponent ._raw_construct (
8989 type = ComponentType .container ,
@@ -96,30 +96,30 @@ def __init__(
9696 for i in items :
9797 self .add_item (i )
9898
99- def _add_component_from_item (self , item : Item ):
99+ def _add_component_from_item (self , item : ViewItem ):
100100 self ._underlying .components .append (item ._underlying )
101101
102- def _set_components (self , items : list [Item ]):
102+ def _set_components (self , items : list [ViewItem ]):
103103 self ._underlying .components .clear ()
104104 for item in items :
105105 self ._add_component_from_item (item )
106106
107- def add_item (self , item : Item ) -> Self :
107+ def add_item (self , item : ViewItem ) -> Self :
108108 """Adds an item to the container.
109109
110110 Parameters
111111 ----------
112- item: :class:`Item `
112+ item: :class:`ViewItem `
113113 The item to add to the container.
114114
115115 Raises
116116 ------
117117 TypeError
118- An :class:`Item ` was not passed.
118+ A :class:`ViewItem ` was not passed.
119119 """
120120
121- if not isinstance (item , Item ):
122- raise TypeError (f"expected Item not { item .__class__ !r} " )
121+ if not isinstance (item , ViewItem ):
122+ raise TypeError (f"expected ViewItem not { item .__class__ !r} " )
123123
124124 if isinstance (item , (Button , Select )):
125125 raise TypeError (
@@ -135,12 +135,12 @@ def add_item(self, item: Item) -> Self:
135135 self ._add_component_from_item (item )
136136 return self
137137
138- def remove_item (self , item : Item | str | int ) -> Self :
138+ def remove_item (self , item : ViewItem | str | int ) -> Self :
139139 """Removes an item from the container. If an int or str is passed, it will remove by Item :attr:`id` or ``custom_id`` respectively.
140140
141141 Parameters
142142 ----------
143- item: Union[:class:`Item `, :class:`int`, :class:`str`]
143+ item: Union[:class:`ViewItem `, :class:`int`, :class:`str`]
144144 The item, ``id``, or item ``custom_id`` to remove from the container.
145145 """
146146
@@ -155,7 +155,7 @@ def remove_item(self, item: Item | str | int) -> Self:
155155 pass
156156 return self
157157
158- def get_item (self , id : str | int ) -> Item | None :
158+ def get_item (self , id : str | int ) -> ViewItem | None :
159159 """Get an item from this container. Roughly equivalent to `utils.get(container.items, ...)`.
160160 If an ``int`` is provided, the item will be retrieved by ``id``, otherwise by ``custom_id``.
161161 This method will also search for nested items.
@@ -167,7 +167,7 @@ def get_item(self, id: str | int) -> Item | None:
167167
168168 Returns
169169 -------
170- Optional[:class:`Item `]
170+ Optional[:class:`ViewItem `]
171171 The item with the matching ``id`` or ``custom_id`` if it exists.
172172 """
173173 if not id :
@@ -183,7 +183,7 @@ def get_item(self, id: str | int) -> Item | None:
183183
184184 def add_row (
185185 self ,
186- * items : Item ,
186+ * items : ViewItem ,
187187 id : int | None = None ,
188188 ) -> Self :
189189 """Adds an :class:`ActionRow` to the container.
@@ -204,8 +204,8 @@ def add_row(
204204
205205 def add_section (
206206 self ,
207- * items : Item ,
208- accessory : Item ,
207+ * items : ViewItem ,
208+ accessory : ViewItem ,
209209 id : int | None = None ,
210210 ) -> Self :
211211 """Adds a :class:`Section` to the container.
@@ -215,10 +215,10 @@ def add_section(
215215
216216 Parameters
217217 ----------
218- *items: :class:`Item `
218+ *items: :class:`ViewItem `
219219 The items contained in this section, up to 3.
220220 Currently only supports :class:`~discord.ui.TextDisplay`.
221- accessory: Optional[:class:`Item `]
221+ accessory: Optional[:class:`ViewItem `]
222222 The section's accessory. This is displayed in the top right of the section.
223223 Currently only supports :class:`~discord.ui.Button` and :class:`~discord.ui.Thumbnail`.
224224 id: Optional[:class:`int`]
@@ -246,7 +246,7 @@ def add_text(self, content: str, id: int | None = None) -> Self:
246246
247247 def add_gallery (
248248 self ,
249- * items : Item ,
249+ * items : ViewItem ,
250250 id : int | None = None ,
251251 ) -> Self :
252252 """Adds a :class:`MediaGallery` to the container.
@@ -338,7 +338,7 @@ def colour(self, value: int | Colour | None): # type: ignore
338338
339339 color = colour
340340
341- @Item .view .setter
341+ @ViewItem .view .setter
342342 def view (self , value ):
343343 self ._view = value
344344 for item in self .items :
@@ -365,13 +365,13 @@ def refresh_component(self, component: ContainerComponent) -> None:
365365 x .refresh_component (y )
366366 i += 1
367367
368- def disable_all_items (self , * , exclusions : list [Item ] | None = None ) -> Self :
368+ def disable_all_items (self , * , exclusions : list [ViewItem ] | None = None ) -> Self :
369369 """
370370 Disables all buttons and select menus in the container.
371371
372372 Parameters
373373 ----------
374- exclusions: Optional[List[:class:`Item `]]
374+ exclusions: Optional[List[:class:`ViewItem `]]
375375 A list of items in `self.items` to not disable from the view.
376376 """
377377 for item in self .walk_items ():
@@ -381,13 +381,13 @@ def disable_all_items(self, *, exclusions: list[Item] | None = None) -> Self:
381381 item .disabled = True
382382 return self
383383
384- def enable_all_items (self , * , exclusions : list [Item ] | None = None ) -> Self :
384+ def enable_all_items (self , * , exclusions : list [ViewItem ] | None = None ) -> Self :
385385 """
386386 Enables all buttons and select menus in the container.
387387
388388 Parameters
389389 ----------
390- exclusions: Optional[List[:class:`Item `]]
390+ exclusions: Optional[List[:class:`ViewItem `]]
391391 A list of items in `self.items` to not enable from the view.
392392 """
393393 for item in self .walk_items ():
@@ -397,7 +397,7 @@ def enable_all_items(self, *, exclusions: list[Item] | None = None) -> Self:
397397 item .disabled = False
398398 return self
399399
400- def walk_items (self ) -> Iterator [Item ]:
400+ def walk_items (self ) -> Iterator [ViewItem ]:
401401 for item in self .items :
402402 if hasattr (item , "walk_items" ):
403403 yield from item .walk_items ()
0 commit comments