Add BeforeDelete to GuildDelete struct (#962)

This commit is contained in:
vertex-admin 2021-08-20 15:48:45 -07:00 committed by GitHub
parent be90532eda
commit d655d6df7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -86,6 +86,7 @@ type GuildUpdate struct {
// GuildDelete is the data for a GuildDelete event. // GuildDelete is the data for a GuildDelete event.
type GuildDelete struct { type GuildDelete struct {
*Guild *Guild
BeforeDelete *Guild `json:"-"`
} }
// GuildBanAdd is the data for a GuildBanAdd event. // GuildBanAdd is the data for a GuildBanAdd event.

View file

@ -836,6 +836,13 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
case *GuildUpdate: case *GuildUpdate:
err = s.GuildAdd(t.Guild) err = s.GuildAdd(t.Guild)
case *GuildDelete: case *GuildDelete:
var old *Guild
old, err = s.Guild(t.ID)
if err == nil {
oldCopy := *old
t.BeforeDelete = &oldCopy
}
err = s.GuildRemove(t.Guild) err = s.GuildRemove(t.Guild)
case *GuildMemberAdd: case *GuildMemberAdd:
// Updates the MemberCount of the guild. // Updates the MemberCount of the guild.