mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 10:53:10 +00:00
Improve component typing
This commit is contained in:
committed by
GitHub
parent
b7e25645dc
commit
7267d18d9e
@ -120,7 +120,6 @@ class Button(Item[V]):
|
||||
raise TypeError(f'expected emoji to be str, Emoji, or PartialEmoji not {emoji.__class__}')
|
||||
|
||||
self._underlying = ButtonComponent._raw_construct(
|
||||
type=ComponentType.button,
|
||||
custom_id=custom_id,
|
||||
url=url,
|
||||
disabled=disabled,
|
||||
|
@ -117,7 +117,6 @@ class Select(Item[V]):
|
||||
options = [] if options is MISSING else options
|
||||
self._underlying = SelectMenu._raw_construct(
|
||||
custom_id=custom_id,
|
||||
type=ComponentType.select,
|
||||
placeholder=placeholder,
|
||||
min_values=min_values,
|
||||
max_values=max_values,
|
||||
|
@ -114,7 +114,6 @@ class TextInput(Item[V]):
|
||||
raise TypeError(f'expected custom_id to be str not {custom_id.__class__!r}')
|
||||
|
||||
self._underlying = TextInputComponent._raw_construct(
|
||||
type=ComponentType.text_input,
|
||||
label=label,
|
||||
style=style,
|
||||
custom_id=custom_id,
|
||||
@ -238,7 +237,7 @@ class TextInput(Item[V]):
|
||||
|
||||
@property
|
||||
def type(self) -> Literal[ComponentType.text_input]:
|
||||
return ComponentType.text_input
|
||||
return self._underlying.type
|
||||
|
||||
def is_dispatchable(self) -> bool:
|
||||
return False
|
||||
|
@ -281,7 +281,7 @@ class View:
|
||||
one of its subclasses.
|
||||
"""
|
||||
view = View(timeout=timeout)
|
||||
for component in _walk_all_components(message.components):
|
||||
for component in _walk_all_components(message.components): # type: ignore
|
||||
view.add_item(_component_to_item(component))
|
||||
return view
|
||||
|
||||
@ -634,7 +634,15 @@ class ViewStore:
|
||||
def remove_message_tracking(self, message_id: int) -> Optional[View]:
|
||||
return self._synced_message_views.pop(message_id, None)
|
||||
|
||||
def update_from_message(self, message_id: int, components: List[ComponentPayload]) -> None:
|
||||
def update_from_message(self, message_id: int, data: List[ComponentPayload]) -> None:
|
||||
components: List[Component] = []
|
||||
|
||||
for component_data in data:
|
||||
component = _component_factory(component_data)
|
||||
|
||||
if component is not None:
|
||||
components.append(component)
|
||||
|
||||
# pre-req: is_message_tracked == true
|
||||
view = self._synced_message_views[message_id]
|
||||
view._refresh([_component_factory(d) for d in components])
|
||||
view._refresh(components)
|
||||
|
Reference in New Issue
Block a user