diff options
| author | Vexs <[email protected]> | 2019-04-09 09:37:58 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-05-09 05:53:56 -0400 |
| commit | 82a39eb148e747bfc8bcd85ae19e4d4b369af5a1 (patch) | |
| tree | a178ae516ac86fc2abc7f39f77eb20fa322952c9 /discord | |
| parent | Mention what can be done during initialisation in embeds. (diff) | |
| download | discord.py-82a39eb148e747bfc8bcd85ae19e4d4b369af5a1.tar.xz discord.py-82a39eb148e747bfc8bcd85ae19e4d4b369af5a1.zip | |
Add cached_message to on_raw_message_edit event
Also add documentation for this behavior
Diffstat (limited to 'discord')
| -rw-r--r-- | discord/raw_models.py | 7 | ||||
| -rw-r--r-- | discord/state.py | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/discord/raw_models.py b/discord/raw_models.py index 211216af..72de4450 100644 --- a/discord/raw_models.py +++ b/discord/raw_models.py @@ -86,14 +86,17 @@ class RawMessageUpdateEvent: The message ID that got updated. data: :class:`dict` The raw data given by the - `gateway <https://discordapp.com/developers/docs/topics/gateway#message-update>`_ + `gateway <https://discordapp.com/developers/docs/topics/gateway#message-update>` + cached_message: Optional[:class:`Message`] + The cached message, if found in the internal message cache. """ - __slots__ = ('message_id', 'data') + __slots__ = ('message_id', 'data', 'cached_message') def __init__(self, data): self.message_id = int(data['id']) self.data = data + self.cached_message = None class RawReactionActionEvent: """Represents the payload for a :func:`on_raw_reaction_add` or diff --git a/discord/state.py b/discord/state.py index a603c55d..f04d6ee7 100644 --- a/discord/state.py +++ b/discord/state.py @@ -386,10 +386,11 @@ class ConnectionState: def parse_message_update(self, data): raw = RawMessageUpdateEvent(data) - self.dispatch('raw_message_edit', raw) message = self._get_message(raw.message_id) if message is not None: 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']) @@ -400,6 +401,8 @@ class ConnectionState: message._update(channel=message.channel, data=data) self.dispatch('message_edit', older_message, message) + else: + self.dispatch('raw_message_edit', raw) def parse_message_reaction_add(self, data): emoji_data = data['emoji'] |