예제 #1
0
파일: conn.go 프로젝트: Skullever/digo
/* may be deprecated by session.Status in discordgo */
func pollConn(s *discordgo.Session) {
	c := config.Get()
	for {
		time.Sleep(10 * time.Second)
		found := false
		guilds, err := s.UserGuilds()
		for _, g := range guilds {
			if g.ID == c.Guild {
				found = true
				break
			}
		}

		if !found {
			log.Warningf("Could not find membership matching guild ID. %s", c.Guild)
			log.Warningf("Maybe I need a new invite? Using code %s", c.InviteID)
			if s.Token != "" {
				s.Close()
			}
			return
		}

		if err != nil {
			log.Warningf("Could not fetch guild info %v", err)
			if s.Token != "" {
				s.Close()
			}
			return
		}
	}
}