From d0097c4281af7aa863e746e977a68517ddaba03b Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 31 May 2021 05:47:46 -0400 Subject: 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. --- discord/interactions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'discord/interactions.py') 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 -- cgit v1.2.3