func (s *State) updateGuild(g *discord.Guild) {
	s.mu.Lock()
	defer s.mu.Unlock()
	old := s.guilds[g.ID]
	if old != nil {
		if g.Roles == nil {
			g.Roles = old.Roles
		}
		if g.Emojis == nil {
			g.Emojis = old.Emojis
		}
		if g.VoiceStates == nil {
			g.VoiceStates = old.VoiceStates
		}
		if g.Members == nil {
			g.Members = old.Members
		}
		if g.Channels == nil {
			g.Channels = old.Channels
		}
		if g.Presences == nil {
			g.Presences = old.Presences
		}
	}
	for i := 0; i < len(g.Channels); i++ {
		ch := &g.Channels[i]
		ch.GuildID = g.ID
		s.channels[ch.ID] = ch
	}
	for i := 0; i < len(g.Members); i++ {
		m := &g.Members[i]
		s.users[m.User.ID] = m.User
	}
	for i := 0; i < len(g.Presences); i++ {
		p := &g.Presences[i]
		s.presences[p.User.ID] = p
	}
	s.guilds[g.ID] = g
	delete(s.unavailableGuilds, g.ID)
}
updateGuild adds the given guild to the state. If it already
exists, it merges its content with the existing guild.
It also removes this guild from the UnavailableGuilds map if
it was present.
package harmony
import (
	"sync"
	"time"
	"github.com/skwair/harmony/discord"
	"github.com/skwair/harmony/voice"
)
type State struct {
	mu sync.RWMutex
	me                *discord.User
	users             map[string]*discord.User
	guilds            map[string]*discord.Guild
	presences         map[string]*discord.Presence  
	channels          map[string]*discord.Channel
	dms               map[string]*discord.Channel
	groups            map[string]*discord.Channel
	unavailableGuilds map[string]*discord.UnavailableGuild
	rtt time.Duration
}
func newState() *State {
	return &State{
		users:             make(map[string]*discord.User),
		guilds:            make(map[string]*discord.Guild),
		presences:         make(map[string]*discord.Presence),
		channels:          make(map[string]*discord.Channel),
		dms:               make(map[string]*discord.Channel),
		groups:            make(map[string]*discord.Channel),
		unavailableGuilds: make(map[string]*discord.UnavailableGuild),
	}
}
func (s *State) Me() *discord.User {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.me.Clone()
}
func (s *State) User(id string) *discord.User {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.users[id].Clone()
}
func (s *State) Guild(id string) *discord.Guild {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.guilds[id].Clone()
}
func (s *State) Channel(id string) *discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.channels[id].Clone()
}
func (s *State) GroupDM(id string) *discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.groups[id].Clone()
}
func (s *State) DM(id string) *discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.dms[id].Clone()
}
func (s *State) Presence(userID string) *discord.Presence {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.presences[userID].Clone()
}
func (s *State) UnavailableGuild(id string) *discord.UnavailableGuild {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.unavailableGuilds[id].Clone()
}
func (s *State) Users() map[string]*discord.User {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.User)
	for k, v := range s.users {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) Guilds() map[string]*discord.Guild {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.Guild)
	for k, v := range s.guilds {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) Channels() map[string]*discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.Channel)
	for k, v := range s.channels {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) GroupDMs() map[string]*discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.Channel)
	for k, v := range s.groups {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) DMs() map[string]*discord.Channel {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.Channel)
	for k, v := range s.dms {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) Presences() map[string]*discord.Presence {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.Presence)
	for k, v := range s.presences {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) UnavailableGuilds() map[string]*discord.UnavailableGuild {
	s.mu.RLock()
	defer s.mu.RUnlock()
	newMap := make(map[string]*discord.UnavailableGuild)
	for k, v := range s.unavailableGuilds {
		newMap[k] = v.Clone()
	}
	return newMap
}
func (s *State) RTT() time.Duration {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.rtt
}
func (s *State) setInitialState(r *Ready) {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.me = r.User
	for i := 0; i < len(r.Guilds); i++ {
		g := &r.Guilds[i]
		if g.Unavailable == nil {
			continue
		}
		s.guilds[g.ID] = &discord.Guild{
			ID:          g.ID,
			Unavailable: *g.Unavailable,
		}
	}
}