Skip to content

fix: 🐛 Fix message._raw_data to be updated when the message is updated #2778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2746])(https://github.com/Pycord-Development/pycord/pull/2746)
- Updated `valid_locales` to support `in` and `es-419`.
([#2767])(https://github.com/Pycord-Development/pycord/pull/2767)
- Fixed `Message._raw_data` to be updated when the message is edited.
([#2778](https://github.com/Pycord-Development/pycord/pull/2778))
- Fixed `Webhook.edit` not working with `attachments=[]`.
([#2779])(https://github.com/Pycord-Development/pycord/pull/2779)

Expand Down
1 change: 1 addition & 0 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ def _update(self, data):
continue
else:
handler(self, value)
self._raw_data[key] = value

# clear the cached properties
for attr in self._CACHED_SLOTS:
Expand Down
2 changes: 2 additions & 0 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ def parse_message_update(self, data) -> None:
message = self._get_message(raw.message_id)
if message is not None:
older_message = copy.copy(message)
# Copy the raw data because copy.copy will keep references to the same object
message._raw_data = copy.deepcopy(message._raw_data)
raw.cached_message = older_message
self.dispatch("raw_message_edit", raw)
message._update(data)
Expand Down