diff --git a/events.go b/events.go index e784cac..8c560db 100644 --- a/events.go +++ b/events.go @@ -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. diff --git a/state.go b/state.go index 695f47c..df1b47a 100644 --- a/state.go +++ b/state.go @@ -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: