@@ -162,6 +162,8 @@ type MessageCreate struct {
// MessageUpdate is the data for a MessageUpdate event.
type MessageUpdate struct {
*Message
+ // BeforeUpdate will be nil if the Message was not previously cached in the state cache.
+ BeforeUpdate *Message `json:"-"`
}
// MessageDelete is the data for a MessageDelete event.
@@ -863,6 +863,12 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
case *MessageUpdate:
if s.MaxMessageCount != 0 {
+ old, err := s.Message(t.ChannelID, t.ID)
+ if err == nil {
+ oldCopy := *old
+ t.BeforeUpdate = &oldCopy
+ }
+
err = s.MessageAdd(t.Message)
case *MessageDelete: