Skip to content

Commit

Permalink
feat(ChannelUpdate): add BeforeUpdate (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincali authored Jul 7, 2024
1 parent 33044e2 commit 4a6d74e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4a6d74e

Please sign in to comment.