Add a swap method for dynamic item's dispatching

This commit is contained in:
DA344
2025-08-21 00:52:31 +02:00
committed by GitHub
parent b2aab86ba1
commit 0309aac335
5 changed files with 26 additions and 3 deletions

View File

@ -67,6 +67,7 @@ if TYPE_CHECKING:
from ..components import SelectOption
from ..interactions import Interaction
from .container import Container
from .dynamic import DynamicItem
SelectCallbackDecorator = Callable[[ItemCallbackType['S', BaseSelectT]], BaseSelectT]
@ -194,6 +195,10 @@ class ActionRow(Item[V]):
# it should error anyways.
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 width(self):
return 5