feat(ChannelUpdate): add BeforeUpdate (#1539)
This commit is contained in:
parent
33044e2858
commit
4a6d74ef80
2 changed files with 6 additions and 0 deletions
|
@ -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.
|
||||
|
|
5
state.go
5
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:
|
||||
|
|
Loading…
Reference in a new issue