10
10
from ..utils import find , get
11
11
from .button import Button
12
12
from .file import File
13
- from .item import Item , ItemCallbackType
13
+ from .item import ViewItem , ItemCallbackType
14
14
from .select import Select
15
15
16
16
__all__ = ("ActionRow" ,)
28
28
V = TypeVar ("V" , bound = "DesignerView" , covariant = True )
29
29
30
30
31
- class ActionRow (Item [V ]):
31
+ class ActionRow (ViewItem [V ]):
32
32
"""Represents a UI Action Row used in :class:`discord.ui.DesignerView`.
33
33
34
34
The items supported are as follows:
@@ -40,7 +40,7 @@ class ActionRow(Item[V]):
40
40
41
41
Parameters
42
42
----------
43
- *items: :class:`Item `
43
+ *items: :class:`ViewItem `
44
44
The initial items in this action row.
45
45
id: Optional[:class:`int`]
46
46
The action's ID.
@@ -64,12 +64,12 @@ def __init_subclass__(cls) -> None:
64
64
65
65
def __init__ (
66
66
self ,
67
- * items : Item ,
67
+ * items : ViewItem ,
68
68
id : int | None = None ,
69
69
):
70
70
super ().__init__ ()
71
71
72
- self .children : list [Item ] = []
72
+ self .children : list [ViewItem ] = []
73
73
74
74
self ._underlying = ActionRowComponent ._raw_construct (
75
75
type = ComponentType .action_row ,
@@ -78,7 +78,7 @@ def __init__(
78
78
)
79
79
80
80
for func in self .__row_children_items__ :
81
- item : Item = func .__discord_ui_model_type__ (
81
+ item : ViewItem = func .__discord_ui_model_type__ (
82
82
** func .__discord_ui_model_kwargs__
83
83
)
84
84
item .callback = partial (func , self , item )
@@ -87,26 +87,26 @@ def __init__(
87
87
for i in items :
88
88
self .add_item (i )
89
89
90
- def _add_component_from_item (self , item : Item ):
90
+ def _add_component_from_item (self , item : ViewItem ):
91
91
self ._underlying .children .append (item ._underlying )
92
92
93
- def _set_components (self , items : list [Item ]):
93
+ def _set_components (self , items : list [ViewItem ]):
94
94
self ._underlying .children .clear ()
95
95
for item in items :
96
96
self ._add_component_from_item (item )
97
97
98
- def add_item (self , item : Item ) -> Self :
98
+ def add_item (self , item : ViewItem ) -> Self :
99
99
"""Adds an item to the action row.
100
100
101
101
Parameters
102
102
----------
103
- item: :class:`Item `
103
+ item: :class:`ViewItem `
104
104
The item to add to the action row.
105
105
106
106
Raises
107
107
------
108
108
TypeError
109
- An :class:`Item ` was not passed.
109
+ A :class:`ViewItem ` was not passed.
110
110
"""
111
111
112
112
if not isinstance (item , (Select , Button )):
@@ -123,12 +123,12 @@ def add_item(self, item: Item) -> Self:
123
123
self ._add_component_from_item (item )
124
124
return self
125
125
126
- def remove_item (self , item : Item | str | int ) -> Self :
126
+ def remove_item (self , item : ViewItem | str | int ) -> Self :
127
127
"""Removes an item from the action row. If an int or str is passed, it will remove by Item :attr:`id` or ``custom_id`` respectively.
128
128
129
129
Parameters
130
130
----------
131
- item: Union[:class:`Item `, :class:`int`, :class:`str`]
131
+ item: Union[:class:`ViewItem `, :class:`int`, :class:`str`]
132
132
The item, ``id``, or item ``custom_id`` to remove from the action row.
133
133
"""
134
134
@@ -140,7 +140,7 @@ def remove_item(self, item: Item | str | int) -> Self:
140
140
pass
141
141
return self
142
142
143
- def get_item (self , id : str | int ) -> Item | None :
143
+ def get_item (self , id : str | int ) -> ViewItem | None :
144
144
"""Get an item from this action row. Roughly equivalent to `utils.get(row.children, ...)`.
145
145
If an ``int`` is provided, the item will be retrieved by ``id``, otherwise by ``custom_id``.
146
146
@@ -151,7 +151,7 @@ def get_item(self, id: str | int) -> Item | None:
151
151
152
152
Returns
153
153
-------
154
- Optional[:class:`Item `]
154
+ Optional[:class:`ViewItem `]
155
155
The item with the matching ``id`` or ``custom_id`` if it exists.
156
156
"""
157
157
if not id :
@@ -327,7 +327,7 @@ def add_select(
327
327
328
328
return self .add_item (select )
329
329
330
- @Item .view .setter
330
+ @ViewItem .view .setter
331
331
def view (self , value ):
332
332
self ._view = value
333
333
for item in self .children :
@@ -352,27 +352,27 @@ def refresh_component(self, component: ActionRowComponent) -> None:
352
352
x .refresh_component (y )
353
353
i += 1
354
354
355
- def disable_all_items (self , * , exclusions : list [Item ] | None = None ) -> Self :
355
+ def disable_all_items (self , * , exclusions : list [ViewItem ] | None = None ) -> Self :
356
356
"""
357
357
Disables all items in the row.
358
358
359
359
Parameters
360
360
----------
361
- exclusions: Optional[List[:class:`Item `]]
361
+ exclusions: Optional[List[:class:`ViewItem `]]
362
362
A list of items in `self.children` to not disable.
363
363
"""
364
364
for item in self .walk_items ():
365
365
if exclusions is None or item not in exclusions :
366
366
item .disabled = True
367
367
return self
368
368
369
- def enable_all_items (self , * , exclusions : list [Item ] | None = None ) -> Self :
369
+ def enable_all_items (self , * , exclusions : list [ViewItem ] | None = None ) -> Self :
370
370
"""
371
371
Enables all items in the row.
372
372
373
373
Parameters
374
374
----------
375
- exclusions: Optional[List[:class:`Item `]]
375
+ exclusions: Optional[List[:class:`ViewItem `]]
376
376
A list of items in `self.children` to not enable.
377
377
"""
378
378
for item in self .walk_items ():
@@ -388,7 +388,7 @@ def width(self):
388
388
t += 1 if item ._underlying .type is ComponentType .button else 5
389
389
return t
390
390
391
- def walk_items (self ) -> Iterator [Item ]:
391
+ def walk_items (self ) -> Iterator [ViewItem ]:
392
392
yield from self .children
393
393
394
394
def to_component_dict (self ) -> ActionRowPayload :
0 commit comments