Browse Source

Fix exception on some MessageUpdates when `commands_allow_edit` was enabled

pull/81/merge
Andrei 7 years ago
parent
commit
5c28ee6508
No known key found for this signature in database GPG Key ID: 4D2A02C7D500E9D9
  1. 25
      disco/bot/bot.py

25
disco/bot/bot.py

@ -400,17 +400,24 @@ class Bot(LoggingClass):
self.last_message_cache[event.message.channel_id] = (event.message, result)
def on_message_update(self, event):
if self.config.commands_allow_edit:
obj = self.last_message_cache.get(event.message.channel_id)
if not obj:
return
if not self.config.commands_allow_edit:
return
# Ignore messages that do not have content, these can happen when only
# some message fields are updated.
if not event.message.content:
return
obj = self.last_message_cache.get(event.message.channel_id)
if not obj:
return
msg, triggered = obj
if msg.id == event.message.id and not triggered:
msg.inplace_update(event.message)
triggered = self.handle_message(msg)
msg, triggered = obj
if msg.id == event.message.id and not triggered:
msg.inplace_update(event.message)
triggered = self.handle_message(msg)
self.last_message_cache[msg.channel_id] = (msg, triggered)
self.last_message_cache[msg.channel_id] = (msg, triggered)
def add_plugin(self, inst, config=None, ctx=None):
"""

Loading…
Cancel
Save