This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-11-27 09:07:48 +07:00
|
|
|
package roles
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
|
|
|
|
"PermissionGacha/modules/config"
|
|
|
|
"PermissionGacha/modules/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GiveLevelRoles(s *discordgo.Session, discordID string, oldLevel, newLevel int) {
|
2019-11-29 14:10:01 +07:00
|
|
|
for i := oldLevel + 1; i <= newLevel; i++ {
|
2019-11-27 09:07:48 +07:00
|
|
|
s.GuildMemberRoleAdd(config.GuildID, discordID, rolesFromLevel[i-1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func RemoveAllLevelRoles(s *discordgo.Session, discordID string) {
|
|
|
|
member, err := s.GuildMember(config.GuildID, discordID)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(s, "RemoveAllLevelRoles", "GuildMember", discordID)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for _, v := range member.Roles {
|
|
|
|
for _, w := range rolesFromLevel {
|
|
|
|
if v == w {
|
|
|
|
s.GuildMemberRoleRemove(config.GuildID, discordID, v)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|