fix: allow user to register if they have 1 role

This assumes that the role is for onboarding purposes in-between seasons

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/19/head
jolheiser 2024-06-17 19:40:33 -05:00
parent 986473e1df
commit 97ddafcaf6
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 25 additions and 20 deletions

View File

@ -19,7 +19,7 @@ func init() {
commands = append(commands, &command{
name: "register",
validate: func(cmd commandInit) bool {
return len(cmd.message.Member.Roles) == 0
return len(cmd.message.Member.Roles) <= 1
},
run: func(cmd commandInit) (string, error) {
args := strings.Fields(cmd.message.Content)
@ -67,13 +67,15 @@ func init() {
return "No application found for that player", nil
}
}
} else if len(apps) > 0 {
} else if len(cmd.message.Member.Roles) == 0 {
if len(apps) > 0 {
if apps[0].Accepted != nil && *apps[0].Accepted {
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
}
}
accepted := apps[0].Accepted
if accepted == nil {
@ -82,6 +84,7 @@ func init() {
return "Your application was denied, good luck finding a new server", nil
}
if nickname != "" {
// Accepted, check for dupe user
guild, err := cmd.session.State.Guild(cmd.message.GuildID)
if err != nil {
@ -100,6 +103,8 @@ func init() {
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 {
return "", err
}