mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-11-21 00:01:32 +00:00
Fix container items having out of date internal state
This commit is contained in:
@@ -39,10 +39,11 @@ from typing import (
|
||||
Sequence,
|
||||
)
|
||||
from contextvars import ContextVar
|
||||
import copy
|
||||
import inspect
|
||||
import os
|
||||
|
||||
from .item import Item, ContainedItemCallbackType as ItemCallbackType
|
||||
from .item import Item, ContainedItemCallbackType as ItemCallbackType, _ItemCallback
|
||||
from ..enums import ChannelType, ComponentType, SelectDefaultValueType
|
||||
from ..partial_emoji import PartialEmoji
|
||||
from ..emoji import Emoji
|
||||
@@ -70,7 +71,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import TypeAlias, TypeGuard
|
||||
from typing_extensions import TypeAlias, TypeGuard, Self
|
||||
|
||||
from .view import BaseView
|
||||
from .action_row import ActionRow
|
||||
@@ -269,6 +270,14 @@ class BaseSelect(Item[V]):
|
||||
self.row = row
|
||||
self._values: List[PossibleValue] = []
|
||||
|
||||
def copy(self) -> Self:
|
||||
new = copy.copy(self)
|
||||
if isinstance(new.callback, _ItemCallback):
|
||||
new.callback.item = new
|
||||
new._parent = self._parent
|
||||
new._update_view(self.view)
|
||||
return new
|
||||
|
||||
@property
|
||||
def id(self) -> Optional[int]:
|
||||
"""Optional[:class:`int`]: The ID of this select."""
|
||||
|
||||
Reference in New Issue
Block a user