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 Rapptz
parent 5333e7c737
commit 735b033701
5 changed files with 26 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ if TYPE_CHECKING:
from ..components import Component
from .action_row import ActionRow
from .container import Container
from .dynamic import DynamicItem
I = TypeVar('I', bound='Item[Any]')
V = TypeVar('V', bound='BaseView', covariant=True)
@@ -118,6 +119,9 @@ class Item(Generic[V]):
return self._provided_custom_id
return True
def _swap_item(self, base: Item, new: DynamicItem, custom_id: str) -> None:
raise ValueError
def __repr__(self) -> str:
attrs = ' '.join(f'{key}={getattr(self, key)!r}' for key in self.__item_repr_attributes__)
return f'<{self.__class__.__name__} {attrs}>'