Browse Source

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.
pull/77/head
Rapptz 9 years ago
parent
commit
0fbb58cde9
  1. 12
      discord/state.py

12
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

Loading…
Cancel
Save