Skip to content

Commit

Permalink
handle cases where regex may not properly compile
Browse files Browse the repository at this point in the history
  • Loading branch information
duckfullstop committed Jun 1, 2024
1 parent a64587a commit 49c1abf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func validateUserCanJoinRole(s *discordgo.Session, u *discordgo.User, guild stri
getRoleName := regexp.MustCompile(`(?i)(?:team):* ?(.*)`)
roleName := getRoleName.FindAllStringSubmatch(role.Name, -1)
// role names get normalized to lower case during the lookup only
if strings.ToLower(roleName[0][1]) == strings.ToLower(targetRole) {
if roleName != nil && strings.ToLower(roleName[0][1]) == strings.ToLower(targetRole) {
// The Member is already part of the given GuildRole!
return errors.New("⚠️ You are already a member of that team!")
}
Expand Down

0 comments on commit 49c1abf

Please sign in to comment.