aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-29 05:52:05 -0400
committerRapptz <[email protected]>2021-05-29 05:52:05 -0400
commitc21d12be5ed2e3d790b1b6744a515120c8b27091 (patch)
tree9555f640ed09e7d96198a5e305f989e07646117d
parentRefactor and type hint invites (diff)
downloaddiscord.py-c21d12be5ed2e3d790b1b6744a515120c8b27091.tar.xz
discord.py-c21d12be5ed2e3d790b1b6744a515120c8b27091.zip
Check future state before setting result in View
-rw-r--r--discord/ui/view.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/discord/ui/view.py b/discord/ui/view.py
index d82a14c3..aa4d52b5 100644
--- a/discord/ui/view.py
+++ b/discord/ui/view.py
@@ -250,7 +250,8 @@ class View:
self._timeout_handler = loop.call_later(self.timeout, self.dispatch_timeout)
def dispatch_timeout(self):
- self._stopped.set_result(True)
+ if not self._stopped.done():
+ self._stopped.set_result(True)
asyncio.create_task(self.on_timeout(), name=f'discord-ui-view-timeout-{self.id}')
def dispatch(self, state: Any, item: Item, interaction: Interaction):
@@ -282,7 +283,9 @@ class View:
This operation cannot be undone.
"""
- self._stopped.set_result(False)
+ if not self._stopped.done():
+ self._stopped.set_result(False)
+
if self._timeout_handler:
self._timeout_handler.cancel()