feat(ChannelUpdate): add BeforeUpdate (#1539)

This commit is contained in:
Kevin Cali 2024-07-07 21:13:33 +02:00 committed by GitHub
parent 33044e2858
commit 4a6d74ef80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -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.

View file

@ -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: