From d7eede35a02185715834e740b530a381511cd41b Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 27 Jun 2023 09:10:07 +0100 Subject: [PATCH] Remove view from ViewWithUserAndRoleCheck.message on interaction stop, if set --- docs/changelog.rst | 5 +++-- pydis_core/utils/interactions.py | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 1e6405c1b..93a70d516 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,8 +3,9 @@ Changelog ========= -- :release:`9.9.2 <26th June 2023>` -- :bug:`184` Bump Discord.py to :literal-url:`2.3.1 `. +- :release:`9.10.0 <27th June 2023>` +- :support:`184` Remove the message, as stored in the ``message`` attr of :obj:`pydis_core.utils.interactions.ViewWithUserAndRoleCheck` when the interaction is stopped, in additional to the exist logic for timeout. +- :support:`184` Bump Discord.py to :literal-url:`2.3.1 `. - :release:`9.9.1 <22th June 2023>` diff --git a/pydis_core/utils/interactions.py b/pydis_core/utils/interactions.py index cb5f26b47..d1227901a 100644 --- a/pydis_core/utils/interactions.py +++ b/pydis_core/utils/interactions.py @@ -80,6 +80,12 @@ async def interaction_check(self, interaction: Interaction) -> bool: await interaction.response.send_message("This is not your button to click!", ephemeral=True) return False + async def stop(self) -> None: + """Stop listening for interactions, and remove the view from ``self.message`` if set.""" + super().stop() + if self.message: + await _handle_modify_message(self.message, "edit") + async def on_timeout(self) -> None: """Remove the view from ``self.message`` if set.""" if self.message: diff --git a/pyproject.toml b/pyproject.toml index 5b1236691..8a6a19cc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pydis_core" -version = "9.9.2" +version = "9.10.0" description = "PyDis core provides core functionality and utility to the bots of the Python Discord community." authors = ["Python Discord "] license = "MIT"