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.
This commit is contained in:
Rapptz
2021-05-31 05:47:46 -04:00
parent 4a3491cc0a
commit d0097c4281
5 changed files with 19 additions and 6 deletions

View File

@ -1437,8 +1437,11 @@ class Webhook(BaseWebhook):
if self.token is None:
raise InvalidArgument('This webhook does not have a token associated with it')
if view is not MISSING and isinstance(self._state, _WebhookState):
raise InvalidArgument('This webhook does not have state associated with it')
if view is not MISSING:
if isinstance(self._state, _WebhookState):
raise InvalidArgument('This webhook does not have state associated with it')
self._state.prevent_view_updates_for(message_id)
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
params = handle_message_parameters(
@ -1462,7 +1465,7 @@ class Webhook(BaseWebhook):
files=params.files,
)
if view:
if view and not view.is_finished():
self._state.store_view(view, message_id)
async def delete_message(self, message_id: int):