mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 09:26:10 +00:00
Add support for components V2
Co-authored-by: Michael H <michael@michaelhall.tech> Co-authored-by: Soheab <33902984+Soheab@users.noreply.github.com> Co-authored-by: owocado <24418520+owocado@users.noreply.github.com> Co-authored-by: Jay3332 <40323796+jay3332@users.noreply.github.com> Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
This commit is contained in:
@ -38,14 +38,12 @@ if TYPE_CHECKING:
|
||||
from ..interactions import Interaction
|
||||
from ..components import Component
|
||||
from ..enums import ComponentType
|
||||
from .view import View
|
||||
|
||||
V = TypeVar('V', bound='View', covariant=True, default=View)
|
||||
from .view import View, LayoutView
|
||||
else:
|
||||
V = TypeVar('V', bound='View', covariant=True)
|
||||
View = LayoutView = Any
|
||||
|
||||
|
||||
class DynamicItem(Generic[BaseT], Item['View']):
|
||||
class DynamicItem(Generic[BaseT], Item[Union[View, LayoutView]]):
|
||||
"""Represents an item with a dynamic ``custom_id`` that can be used to store state within
|
||||
that ``custom_id``.
|
||||
|
||||
@ -57,9 +55,10 @@ class DynamicItem(Generic[BaseT], Item['View']):
|
||||
and should not be used long term. Their only purpose is to act as a "template"
|
||||
for the actual dispatched item.
|
||||
|
||||
When this item is generated, :attr:`view` is set to a regular :class:`View` instance
|
||||
from the original message given from the interaction. This means that custom view
|
||||
subclasses cannot be accessed from this item.
|
||||
When this item is generated, :attr:`view` is set to a regular :class:`View` instance,
|
||||
but to a :class:`LayoutView` if the component was sent with one, this is obtained from
|
||||
the original message given from the interaction. This means that custom view subclasses
|
||||
cannot be accessed from this item.
|
||||
|
||||
.. versionadded:: 2.4
|
||||
|
||||
|
Reference in New Issue
Block a user