28 lines
572 B
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
|
|
}
|