From 4a6d74ef80cb33b3624aab9c4a6329e72430d57e Mon Sep 17 00:00:00 2001 From: Kevin Cali <20154415+kevincali@users.noreply.github.com> Date: Sun, 7 Jul 2024 21:13:33 +0200 Subject: [PATCH] feat(ChannelUpdate): add BeforeUpdate (#1539) --- events.go | 1 + state.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/events.go b/events.go index c2a9d20d0..e19290ec0 100644 --- a/events.go +++ b/events.go @@ -53,6 +53,7 @@ type ChannelCreate struct { // ChannelUpdate is the data for a ChannelUpdate event. type ChannelUpdate struct { *Channel + BeforeUpdate *Channel `json:"-"` } // ChannelDelete is the data for a ChannelDelete event. diff --git a/state.go b/state.go index d0c7b4222..bac4bf3f3 100644 --- a/state.go +++ b/state.go @@ -1056,6 +1056,11 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) { } case *ChannelUpdate: if s.TrackChannels { + old, err := s.Channel(t.ID) + if err == nil { + oldCopy := *old + t.BeforeUpdate = &oldCopy + } err = s.ChannelAdd(t.Channel) } case *ChannelDelete: