diff options
author | 2023-06-26 09:45:16 +0100 | |
---|---|---|
committer | 2023-07-14 13:20:00 +0100 | |
commit | ff765b41eb005865c12c662a786761961a7ec616 (patch) | |
tree | f2a31e3b2cbf9803f7d89429a33ed2e5c1a10999 | |
parent | Bump dev deps (diff) |
Update code for new linter rules
-rw-r--r-- | docs/changelog.rst | 3 | ||||
-rw-r--r-- | pydis_core/async_stats.py | 2 | ||||
-rw-r--r-- | pydis_core/utils/interactions.py | 7 |
3 files changed, 10 insertions, 2 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst index 9abd475a..e8cc8ca0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,8 +5,9 @@ Changelog ========= +- :feature:`184` Remove the message 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 <https://github.com/Rapptz/discord.py/releases/tag/v2.3.1>`. - :bug:`187` Fix :obj:`pydis_core.utils.channel.get_or_fetch_channel`'s return type to include :obj:`discord.abc.PrivateChannel` and :obj:`discord.Thread`. -- :bug:`184` Bump Discord.py to :literal-url:`2.3.1 <https://github.com/Rapptz/discord.py/releases/tag/v2.3.1>`. - :release:`9.9.2 <2nd July 2023>` diff --git a/pydis_core/async_stats.py b/pydis_core/async_stats.py index ae409467..4c94d856 100644 --- a/pydis_core/async_stats.py +++ b/pydis_core/async_stats.py @@ -16,7 +16,7 @@ class AsyncStatsClient(StatsClientBase): loop: asyncio.AbstractEventLoop, host: str = "localhost", port: int = 8125, - prefix: str = None + prefix: str | None = None ): """ Create a new :obj:`AsyncStatsClient`. diff --git a/pydis_core/utils/interactions.py b/pydis_core/utils/interactions.py index cb5f26b4..d3432c3a 100644 --- a/pydis_core/utils/interactions.py +++ b/pydis_core/utils/interactions.py @@ -4,6 +4,7 @@ from typing import Literal from discord import ButtonStyle, HTTPException, Interaction, Message, NotFound, ui from pydis_core.utils.logging import get_logger +from pydis_core.utils.scheduling import create_task log = get_logger(__name__) @@ -80,6 +81,12 @@ class ViewWithUserAndRoleCheck(ui.View): await interaction.response.send_message("This is not your button to click!", ephemeral=True) return False + def stop(self) -> None: + """Stop listening for interactions, and remove the view from ``self.message`` if set.""" + super().stop() + if self.message: + create_task(_handle_modify_message(self.message, "edit")) + async def on_timeout(self) -> None: """Remove the view from ``self.message`` if set.""" if self.message: |