本文整理汇总了Golang中github.com/bwmarrin/discordgo.Session.GuildMemberMove方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.GuildMemberMove方法的具体用法?Golang Session.GuildMemberMove怎么用?Golang Session.GuildMemberMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/bwmarrin/discordgo.Session
的用法示例。
在下文中一共展示了Session.GuildMemberMove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: banUser
func banUser(s *discordgo.Session, guild *discordgo.Guild,
author *discordgo.Member, channelID string, arr []string) {
if len(arr) == 4 && len(arr[2]) == 21 &&
checkForPermissions(s, channelID, author.Roles) {
arr[2] = arr[2][2 : len(arr[2])-1]
userRole := ""
username := ""
for _, member := range guild.Members {
if arr[2] == member.User.ID {
username = member.User.Username
userRole = member.Roles[0]
break
}
}
duration, _ := (strconv.Atoi(arr[3]))
pgDb := dbConn()
tx, err := pgDb.Begin()
checkErr(err)
rows, err := tx.Query(
`SELECT duration FROM bans
WHERE user_id = $1`, arr[2])
checkErr(err)
var (
dur int
i int
)
for rows.Next() {
i++
rows.Scan(&dur)
}
rows.Close()
if i == 0 {
_, err = tx.Exec(
`INSERT INTO bans(name, time_stamp, duration,
guild_id, role_id, user_id)
VALUES($1, $2, $3, $4, $5, $6)`,
username, int64(time.Now().Unix()),
duration*60, guild.ID, userRole, arr[2])
checkErr(err)
s.GuildMemberEdit(guild.ID, arr[2], []string{roleBannedId})
for _, c := range guild.Channels {
if c.Name == "AFK" {
s.GuildMemberMove(guild.ID, arr[2], c.ID)
break
}
}
s.ChannelMessageSend(channelID,
fmt.Sprintf(
"User %s has been temporary banned for %d minute(s)",
username, duration))
} else {
_, err = tx.Exec(
`UPDATE bans SET duration = $1
WHERE user_id = $2`, dur+duration*60, arr[2])
checkErr(err)
s.ChannelMessageSend(channelID,
fmt.Sprintf(
"Users %s temporary ban has been extended by %d minute(s)",
username, duration))
}
tx.Commit()
pgDb.Close()
} else {
s.ChannelMessageSend(channelID,
fmt.Sprintf("Please check the parameters"))
}
}