object-Object / Yot

A moderation and utility Discord bot, written in Lua.
MIT License
4 stars 1 forks source link

The oldContent field of message objects is unreliable #13

Open object-Object opened 4 years ago

object-Object commented 4 years ago

Since Discordia weakly caches messages, message.oldContent is unreliable. If the message is uncached, the following code, when run in the messageUpdate event, will fail on line 2, not line 1:

assert(message.oldContent)
assert(message.oldContent[message.editedTimestamp])

This leaves two options:

  1. If a message is uncached, just tell the user that the old content couldn't be found.

  2. Manually cache all messages in the database.