From bda7434f18fd9c962e901adcd49fabff43e256a4 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Fri, 22 Apr 2016 16:53:57 -0500 Subject: [PATCH] Moved State struct to state.go --- state.go | 16 ++++++++++++++-- structs.go | 12 ------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/state.go b/state.go index c6d3efc..07b7252 100644 --- a/state.go +++ b/state.go @@ -17,6 +17,18 @@ import "errors" // ErrNilState is returned when the state is nil. var ErrNilState = errors.New("State not instantiated, please use discordgo.New() or assign Session.State.") +// A State contains the current known state. +// As discord sends this in a READY blob, it seems reasonable to simply +// use that struct as the data store. +type State struct { + sync.RWMutex + Ready + MaxMessageCount int + + guildMap map[string]*Guild + channelMap map[string]*Channel +} + // NewState creates an empty state. func NewState() *State { return &State{ @@ -105,7 +117,7 @@ func (s *State) GuildRemove(guild *Guild) error { s.Lock() defer s.Unlock() - + delete(s.guildMap, guild.ID) for i, g := range s.Guilds { @@ -286,7 +298,7 @@ func (s *State) ChannelRemove(channel *Channel) error { } } } - + delete(s.channelMap, channel.ID) return nil diff --git a/structs.go b/structs.go index 258cae5..48145a6 100644 --- a/structs.go +++ b/structs.go @@ -393,18 +393,6 @@ type UserGuildSettings struct { ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"` } -// A State contains the current known state. -// As discord sends this in a READY blob, it seems reasonable to simply -// use that struct as the data store. -type State struct { - sync.RWMutex - Ready - MaxMessageCount int - - guildMap map[string]*Guild - channelMap map[string]*Channel -} - // Constants for the different bit offsets of text channel permissions const ( PermissionReadMessages = 1 << (iota + 10)