本文整理汇总了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
}
}
}
示例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
}
示例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
}