Sfoglia il codice sorgente

Merge pull request #168 from iopred/patch-4

Remove items from the map before returning :ok_hand:
Bruce 8 anni fa
parent
commit
f654ec2a42
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 4 4
      state.go

+ 4 - 4
state.go

@@ -105,6 +105,8 @@ func (s *State) GuildRemove(guild *Guild) error {
 
 	s.Lock()
 	defer s.Unlock()
+	
+	delete(s.guildMap, guild.ID)
 
 	for i, g := range s.Guilds {
 		if g.ID == guild.ID {
@@ -113,8 +115,6 @@ func (s *State) GuildRemove(guild *Guild) error {
 		}
 	}
 
-	delete(s.guildMap, guild.ID)
-
 	return nil
 }
 
@@ -259,6 +259,8 @@ func (s *State) ChannelRemove(channel *Channel) error {
 	if err != nil {
 		return err
 	}
+	
+	delete(s.channelMap, channel.ID)
 
 	if channel.IsPrivate {
 		s.Lock()
@@ -287,8 +289,6 @@ func (s *State) ChannelRemove(channel *Channel) error {
 		}
 	}
 
-	delete(s.channelMap, channel.ID)
-
 	return nil
 }