本文整理匯總了Golang中github.com/bwmarrin/discordgo.Session.GuildMemberNickname方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.GuildMemberNickname方法的具體用法?Golang Session.GuildMemberNickname怎麽用?Golang Session.GuildMemberNickname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/bwmarrin/discordgo.Session
的用法示例。
在下文中一共展示了Session.GuildMemberNickname方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: nickChangeUpdateCallback
func nickChangeUpdateCallback(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
nicknames := nickCollection{ramendb.GetCollection(m.GuildID, nickCollName)}
guild, _ := s.State.Guild(m.GuildID)
if guild == nil {
log.WithFields(log.Fields{
"guild": m.GuildID,
}).Warning("Failed to grab guild")
return
}
member := m.Member
user := member.User
if member == nil {
log.WithFields(log.Fields{
"member": member,
}).Warning("Failed to grab member")
return
}
if member.User.Bot {
return
}
data := nicknameConfig{}
nicknames.Find(nicknameConfig{UserID: user.ID}).One(&data)
trueNick := data.Nickname
if trueNick == "" {
log.Debug("No Nickname DB Info")
return
}
if member.Nick != trueNick {
err := s.GuildMemberNickname(guild.ID, user.ID, trueNick)
if err != nil {
log.Errorf("Failed to correct user's nickname: %v", err)
return
}
return
}
}