fix: allow user to register if they have 1 role #19

Merged
jolheiser merged 2 commits from limbo into main 2024-06-18 17:15:13 +00:00
1 changed files with 20 additions and 20 deletions

View File

@ -67,38 +67,38 @@ func init() {
return "No application found for that player", nil return "No application found for that player", nil
} }
} }
} else if len(apps) > 0 { }
if apps[0].Accepted != nil && *apps[0].Accepted { if len(apps) == 0 {
return fmt.Sprintf("Please join the server at `%s` and then re-try this command", cmd.config.Register.URL), nil
}
} else {
return "No player or applications found for that username", nil return "No player or applications found for that username", nil
} }
accepted := apps[0].Accepted
accepted := apps[0].Accepted
if accepted == nil { if accepted == nil {
return "Your application is still being reviewed, hang tight", nil return "Your application is still being reviewed, hang tight", nil
} else if !*accepted { } else if !*accepted {
return "Your application was denied, good luck finding a new server", nil return "Your application was denied, good luck finding a new server", nil
} }
// Accepted, check for dupe user if nickname != "" {
guild, err := cmd.session.State.Guild(cmd.message.GuildID) // Accepted, check for dupe user
if err != nil { guild, err := cmd.session.State.Guild(cmd.message.GuildID)
return "", err if err != nil {
} return "", err
for _, member := range guild.Members {
nick := member.Nick
if nick == "" {
nick = member.User.Username
} }
if strings.EqualFold(nickname, nick) && cmd.message.Author.ID != member.User.ID { for _, member := range guild.Members {
return "A member with that name already exists in this Discord. Please contact staff.", nil nick := member.Nick
if nick == "" {
nick = member.User.Username
}
if strings.EqualFold(nickname, nick) && cmd.message.Author.ID != member.User.ID {
return "A member with that name already exists in this Discord. Please contact staff.", nil
}
}
if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil {
return "", err
} }
}
if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil {
return "", err
} }
if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil { if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil {
return "", err return "", err