當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Session.UserGuilds方法代碼示例

本文整理匯總了Golang中github.com/bwmarrin/discordgo.Session.UserGuilds方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.UserGuilds方法的具體用法?Golang Session.UserGuilds怎麽用?Golang Session.UserGuilds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/bwmarrin/discordgo.Session的用法示例。


在下文中一共展示了Session.UserGuilds方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: pollConn

/* 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
		}
	}
}
開發者ID:Skullever,項目名稱:digo,代碼行數:32,代碼來源:conn.go

示例2: fetchPrimaryTextChannelID

func fetchPrimaryTextChannelID(sess *discordgo.Session) string {
	var channelid string
	retryOnBadGateway(func() error {
		guilds, err := sess.UserGuilds()
		if err != nil {
			return err
		}
		guild, err := sess.Guild(guilds[0].ID)
		if err != nil {
			return err
		}
		channels, err := sess.GuildChannels(guild.ID)
		if err != nil {
			return err
		}
		for _, channel := range channels {
			channel, err = sess.Channel(channel.ID)
			if err != nil {
				return err
			}
			if channel.Type == "text" {
				channelid = channel.ID
				return nil
			}
		}
		return errors.New("No primary channel found")
	})
	return channelid
}
開發者ID:dhedegaard,項目名稱:notibot,代碼行數:29,代碼來源:notibot.go

示例3: SetGuildState

//SetGuildState sets the Guild inside the State
func SetGuildState(dg *discordgo.Session) {
	State.InsertMode = false
	Guilds, _ := dg.UserGuilds()
	d := color.New(color.FgYellow, color.Bold)
	d.Printf("Select a Guild:\n")

	for key, guild := range Guilds {
		fmt.Printf("%d:%s\n", key, guild.Name)
	}

	var response int
	fmt.Scanf("%d\n", &response)

	State.Guild, _ = dg.Guild(Guilds[response].ID)
	Clear()

	State.InsertMode = true
}
開發者ID:iopred,項目名稱:discord-cli,代碼行數:19,代碼來源:init.go


注:本文中的github.com/bwmarrin/discordgo.Session.UserGuilds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。