aboutsummaryrefslogtreecommitdiff
path: root/discord/interactions.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-31 05:47:46 -0400
committerRapptz <[email protected]>2021-05-31 05:50:40 -0400
commitd0097c4281af7aa863e746e977a68517ddaba03b (patch)
tree28564dd01423aeb908fc329158f305415684febc /discord/interactions.py
parentCheck for view finished state before resuming listening on edit (diff)
downloaddiscord.py-d0097c4281af7aa863e746e977a68517ddaba03b.tar.xz
discord.py-d0097c4281af7aa863e746e977a68517ddaba03b.zip
Remove view syncing before editing in views
This prevents a potential race condition when a MESSAGE_UPDATE is received syncing and refreshing the view components causing a desync.
Diffstat (limited to 'discord/interactions.py')
-rw-r--r--discord/interactions.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/discord/interactions.py b/discord/interactions.py
index 3ff8d84f..be2743e6 100644
--- a/discord/interactions.py
+++ b/discord/interactions.py
@@ -377,6 +377,9 @@ class InteractionResponse:
return
parent = self._parent
+ msg = parent.message
+ state = parent._state
+ message_id = msg.id if msg else None
if parent.type is not InteractionType.component:
return
@@ -404,6 +407,7 @@ class InteractionResponse:
payload['attachments'] = [a.to_dict() for a in attachments]
if view is not MISSING:
+ state.prevent_view_updates_for(message_id)
if view is None:
payload['components'] = []
else:
@@ -419,8 +423,6 @@ class InteractionResponse:
)
if view is not MISSING and not view.is_finished():
- msg = self._parent.message
- message_id = msg.id if msg else None
- self._parent._state.store_view(view, message_id)
+ state.store_view(view, message_id)
self._responded = True