mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 09:26:10 +00:00
Add a swap method for dynamic item's dispatching
This commit is contained in:
@ -50,6 +50,7 @@ if TYPE_CHECKING:
|
||||
|
||||
from ..components import Container as ContainerComponent
|
||||
from ..interactions import Interaction
|
||||
from .dynamic import DynamicItem
|
||||
|
||||
S = TypeVar('S', bound='Container', covariant=True)
|
||||
V = TypeVar('V', bound='LayoutView', covariant=True)
|
||||
@ -198,6 +199,10 @@ class Container(Item[V]):
|
||||
def _has_children(self):
|
||||
return True
|
||||
|
||||
def _swap_item(self, base: Item, new: DynamicItem, custom_id: str) -> None:
|
||||
child_index = self._children.index(base)
|
||||
self._children[child_index] = new # type: ignore
|
||||
|
||||
@property
|
||||
def children(self) -> List[Item[V]]:
|
||||
"""List[:class:`Item`]: The children of this container."""
|
||||
|
Reference in New Issue
Block a user