Browse Source

Avoid a potential issue where State tracking was disabled and it would return a stale Guild.

Chris Rhodes 9 years ago
parent
commit
a6a218d2fd
1 changed files with 6 additions and 4 deletions
  1. 6 4
      restapi.go

+ 6 - 4
restapi.go

@@ -321,10 +321,12 @@ func (s *Session) UserGuilds() (st []*Guild, err error) {
 // Guild returns a Guild structure of a specific Guild.
 // guildID   : The ID of a Guild
 func (s *Session) Guild(guildID string) (st *Guild, err error) {
-	// Attempt to grab the guild from State first.
-	st, err = s.State.Guild(guildID)
-	if err == nil {
-		return
+	if s.StateEnabled {
+		// Attempt to grab the guild from State first.
+		st, err = s.State.Guild(guildID)
+		if err == nil {
+			return
+		}
 	}
 
 	body, err := s.Request("GET", GUILD(guildID), nil)