package roles import ( "github.com/bwmarrin/discordgo" "PermissionGacha/modules/config" "PermissionGacha/modules/log" ) func GiveLevelRoles(s *discordgo.Session, discordID string, oldLevel, newLevel int) error { for i := oldLevel + 1; i <= newLevel; i++ { err := s.GuildMemberRoleAdd(config.GuildID, discordID, config.LevelRoles[i-1]) if err != nil { return err } } return nil } 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 config.LevelRoles { if v == w { s.GuildMemberRoleRemove(config.GuildID, discordID, v) break } } } }