This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PermissionGacha/modules/roles/check.go

28 lines
572 B
Go

package roles
import (
"fmt"
"github.com/bwmarrin/discordgo"
"PermissionGacha/modules/config"
)
func GetOldLevel(s *discordgo.Session, id string) (int, error) {
member, err := s.GuildMember(config.GuildID, id)
if err != nil {
return 0, fmt.Errorf("roles: EligibleGachaCount: error fetching guild member (%s): %w", id, err)
}
foundLevel := 0
levelSearchLoop:
for i := len(config.LevelRoles); i > 0; i-- {
for _, v := range member.Roles {
if config.LevelRoles[i-1] == v {
foundLevel = i
break levelSearchLoop
}
}
}
return foundLevel, nil
}