mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-03 10:32:42 +00:00
Mark state refresh methods as private with an underscore
People kept wondering what it is or what it does.
This commit is contained in:
parent
6dd8845e4f
commit
934ab4151a
@ -224,7 +224,7 @@ class Button(Item[V]):
|
||||
return self.url is not None
|
||||
return super().is_persistent()
|
||||
|
||||
def refresh_component(self, button: ButtonComponent) -> None:
|
||||
def _refresh_component(self, button: ButtonComponent) -> None:
|
||||
self._underlying = button
|
||||
|
||||
|
||||
|
@ -72,10 +72,10 @@ class Item(Generic[V]):
|
||||
def to_component_dict(self) -> Dict[str, Any]:
|
||||
raise NotImplementedError
|
||||
|
||||
def refresh_component(self, component: Component) -> None:
|
||||
def _refresh_component(self, component: Component) -> None:
|
||||
return None
|
||||
|
||||
def refresh_state(self, data: Dict[str, Any]) -> None:
|
||||
def _refresh_state(self, data: Dict[str, Any]) -> None:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
@ -171,7 +171,7 @@ class Modal(View):
|
||||
print(f'Ignoring exception in modal {self}:', file=sys.stderr)
|
||||
traceback.print_exception(error.__class__, error, error.__traceback__, file=sys.stderr)
|
||||
|
||||
def refresh(self, components: Sequence[ModalSubmitComponentInteractionDataPayload]) -> None:
|
||||
def _refresh(self, components: Sequence[ModalSubmitComponentInteractionDataPayload]) -> None:
|
||||
for component in components:
|
||||
if component['type'] == 1:
|
||||
self.refresh(component['components'])
|
||||
@ -180,7 +180,7 @@ class Modal(View):
|
||||
if item is None:
|
||||
_log.debug("Modal interaction referencing unknown item custom_id %s. Discarding", component['custom_id'])
|
||||
continue
|
||||
item.refresh_state(component) # type: ignore
|
||||
item._refresh_state(component) # type: ignore
|
||||
|
||||
async def _scheduled_task(self, interaction: Interaction):
|
||||
try:
|
||||
|
@ -266,10 +266,10 @@ class Select(Item[V]):
|
||||
def to_component_dict(self) -> SelectMenuPayload:
|
||||
return self._underlying.to_dict()
|
||||
|
||||
def refresh_component(self, component: SelectMenu) -> None:
|
||||
def _refresh_component(self, component: SelectMenu) -> None:
|
||||
self._underlying = component
|
||||
|
||||
def refresh_state(self, data: MessageComponentInteractionData) -> None:
|
||||
def _refresh_state(self, data: MessageComponentInteractionData) -> None:
|
||||
self._selected_values = data.get('values', [])
|
||||
|
||||
@classmethod
|
||||
|
@ -207,10 +207,10 @@ class TextInput(Item[V]):
|
||||
def to_component_dict(self) -> TextInputPayload:
|
||||
return self._underlying.to_dict()
|
||||
|
||||
def refresh_component(self, component: TextInputComponent) -> None:
|
||||
def _refresh_component(self, component: TextInputComponent) -> None:
|
||||
self._underlying = component
|
||||
|
||||
def refresh_state(self, data: ModalSubmitTextInputInteractionDataPayload) -> None:
|
||||
def _refresh_state(self, data: ModalSubmitTextInputInteractionDataPayload) -> None:
|
||||
self._value = data.get('value', None)
|
||||
|
||||
@classmethod
|
||||
|
@ -397,7 +397,7 @@ class View:
|
||||
|
||||
asyncio.create_task(self._scheduled_task(item, interaction), name=f'discord-ui-view-dispatch-{self.id}')
|
||||
|
||||
def refresh(self, components: List[Component]) -> None:
|
||||
def _refresh(self, components: List[Component]) -> None:
|
||||
# This is pretty hacky at the moment
|
||||
# fmt: off
|
||||
old_state: Dict[Tuple[int, str], Item[Any]] = {
|
||||
@ -413,7 +413,7 @@ class View:
|
||||
except (KeyError, AttributeError):
|
||||
children.append(_component_to_item(component))
|
||||
else:
|
||||
older.refresh_component(component)
|
||||
older._refresh_component(component)
|
||||
children.append(older)
|
||||
|
||||
self.children = children
|
||||
@ -536,7 +536,7 @@ class ViewStore:
|
||||
return
|
||||
|
||||
view, item = value
|
||||
item.refresh_state(interaction.data) # type: ignore
|
||||
item._refresh_state(interaction.data) # type: ignore
|
||||
view._dispatch_item(item, interaction)
|
||||
|
||||
def dispatch_modal(
|
||||
@ -550,7 +550,7 @@ class ViewStore:
|
||||
_log.debug("Modal interaction referencing unknown custom_id %s. Discarding", custom_id)
|
||||
return
|
||||
|
||||
modal.refresh(components)
|
||||
modal._refresh(components)
|
||||
modal._dispatch_submit(interaction)
|
||||
|
||||
def is_message_tracked(self, message_id: int) -> bool:
|
||||
@ -562,4 +562,4 @@ class ViewStore:
|
||||
def update_from_message(self, message_id: int, components: List[ComponentPayload]) -> None:
|
||||
# pre-req: is_message_tracked == true
|
||||
view = self._synced_message_views[message_id]
|
||||
view.refresh([_component_factory(d) for d in components])
|
||||
view._refresh([_component_factory(d) for d in components])
|
||||
|
Loading…
x
Reference in New Issue
Block a user