diff --git a/discord/ui/button.py b/discord/ui/button.py index 6e6da1fc6..457a632c6 100644 --- a/discord/ui/button.py +++ b/discord/ui/button.py @@ -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 diff --git a/discord/ui/item.py b/discord/ui/item.py index 9bace2583..a80875a12 100644 --- a/discord/ui/item.py +++ b/discord/ui/item.py @@ -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 diff --git a/discord/ui/modal.py b/discord/ui/modal.py index 1f6e2c42a..6c73a6cb3 100644 --- a/discord/ui/modal.py +++ b/discord/ui/modal.py @@ -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: diff --git a/discord/ui/select.py b/discord/ui/select.py index 13bd542c9..87de5450a 100644 --- a/discord/ui/select.py +++ b/discord/ui/select.py @@ -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 diff --git a/discord/ui/text_input.py b/discord/ui/text_input.py index e38ce5795..d9bfbfc21 100644 --- a/discord/ui/text_input.py +++ b/discord/ui/text_input.py @@ -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 diff --git a/discord/ui/view.py b/discord/ui/view.py index 234a6e6e1..83a179c9a 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -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])