Trim raw string code value, check length of 2nd group before Atoi

This commit is contained in:
2024-02-16 15:14:33 -06:00
parent 07b3146868
commit 5c4a8c0db0

View File

@@ -82,7 +82,7 @@ func SearchCommandHandler(session *discordgo.Session, interaction *discordgo.Int
case "code": case "code":
var low, high int var low, high int
var err error var err error
valueRaw := option.StringValue() valueRaw := strings.TrimSpace(option.StringValue())
// 4 digit code // 4 digit code
if len(valueRaw) == 4 { if len(valueRaw) == 4 {
@@ -109,7 +109,7 @@ func SearchCommandHandler(session *discordgo.Session, interaction *discordgo.Int
} }
// If there's not a high value, set it to the low value // If there's not a high value, set it to the low value
if len(match) == 2 { if len(match) == 2 || len(match[2]) == 0 {
high = low high = low
} else { } else {
high, err = strconv.Atoi(string(match[2])) high, err = strconv.Atoi(string(match[2]))