aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-01-07 01:27:13 -0500
committerRapptz <[email protected]>2016-01-07 01:27:38 -0500
commit0fbb58cde9b787dfdc2d027e2d91c6fb450ed2ed (patch)
tree341aaf46882de3c82f085fee1bc56fe26be028f4
parentAdd missing roles attribute to Server.__slots__ (diff)
downloaddiscord.py-0fbb58cde9b787dfdc2d027e2d91c6fb450ed2ed.tar.xz
discord.py-0fbb58cde9b787dfdc2d027e2d91c6fb450ed2ed.zip
Change the way MESSAGE_UPDATE events are handled.
Previously we created a copy of the object and did some strange iteration over the data and set the attributes that we thought were valid. This worked back then in v0.1.0 of the library when it was written, but it no longer works nowadays when we want to be as future proof as possible.
-rw-r--r--discord/state.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/discord/state.py b/discord/state.py
index 06ec6ffb..3de55a69 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -92,17 +92,7 @@ class ConnectionState:
def parse_message_update(self, data):
older_message = self._get_message(data.get('id'))
if older_message is not None:
- # create a copy of the new message
- message = copy.copy(older_message)
- # update the new update
- for attr in data:
- if attr == 'channel_id' or attr == 'author':
- continue
- value = data[attr]
- if 'time' in attr:
- setattr(message, attr, utils.parse_time(value))
- else:
- setattr(message, attr, value)
+ message = Message(channel=older_message.channel, **data)
self.dispatch('message_edit', older_message, message)
# update the older message
older_message = message