diff options
| author | Rapptz <[email protected]> | 2021-05-31 05:47:46 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-05-31 05:50:40 -0400 |
| commit | d0097c4281af7aa863e746e977a68517ddaba03b (patch) | |
| tree | 28564dd01423aeb908fc329158f305415684febc /discord/webhook | |
| parent | Check for view finished state before resuming listening on edit (diff) | |
| download | discord.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/webhook')
| -rw-r--r-- | discord/webhook/async_.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index faea82a3..d73ab0ea 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -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): |