Improve performance of parsing MESSAGE_UPDATE and MESSAGE_CREATE events

Embed edits are no longer special cased in the dispatch code, which
could lead to on_message_edit being called more often than it used to
be called. I am not sure on the general impact on that being removed.

Fixes #2195
This commit is contained in:
Rapptz
2019-06-07 22:18:01 -04:00
parent 3c9bcc2851
commit f84219c2b2
2 changed files with 67 additions and 29 deletions

View File

@ -397,15 +397,7 @@ class ConnectionState:
older_message = copy.copy(message)
raw.cached_message = older_message
self.dispatch('raw_message_edit', raw)
if 'call' in data:
# call state message edit
message._handle_call(data['call'])
elif 'content' not in data:
# embed only edit
message.embeds = [Embed.from_dict(d) for d in data['embeds']]
else:
message._update(channel=message.channel, data=data)
message._update(data)
self.dispatch('message_edit', older_message, message)
else:
self.dispatch('raw_message_edit', raw)