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>
parent
986473e1df
commit
296c7ec3c6
|
@ -19,7 +19,7 @@ func init() {
|
||||||
commands = append(commands, &command{
|
commands = append(commands, &command{
|
||||||
name: "register",
|
name: "register",
|
||||||
validate: func(cmd commandInit) bool {
|
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) {
|
run: func(cmd commandInit) (string, error) {
|
||||||
args := strings.Fields(cmd.message.Content)
|
args := strings.Fields(cmd.message.Content)
|
||||||
|
@ -67,7 +67,7 @@ func init() {
|
||||||
return "No application found for that player", nil
|
return "No application found for that player", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if len(apps) > 0 {
|
} else if len(apps) > 0 && len(cmd.message.Member.Roles) == 0 {
|
||||||
if apps[0].Accepted != nil && *apps[0].Accepted {
|
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
|
return fmt.Sprintf("Please join the server at `%s` and then re-try this command", cmd.config.Register.URL), nil
|
||||||
}
|
}
|
||||||
|
@ -82,23 +82,26 @@ func init() {
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue