Преглед изворни кода

Backport retrieving Guilds from State to develop. Fix bugs when Guild is Unavailable

Chris Rhodes пре 6 година
родитељ
комит
b86482cd77
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      restapi.go

+ 8 - 0
restapi.go

@@ -578,6 +578,14 @@ func memberPermissions(guild *Guild, channel *Channel, member *Member) (apermiss
 // 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) {
+	if s.StateEnabled {
+		// Attempt to grab the guild from State first.
+		st, err = s.State.Guild(guildID)
+		if err == nil && !st.Unavailable {
+			return
+		}
+	}
+
 	body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID), nil, EndpointGuild(guildID))
 	if err != nil {
 		return