From 5c4a8c0db020c3e6d8de2dca066f521aa7f4b379 Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 16 Feb 2024 15:14:33 -0600 Subject: [PATCH] Trim raw string code value, check length of 2nd group before Atoi --- commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index a67dff1..f89869d 100644 --- a/commands.go +++ b/commands.go @@ -82,7 +82,7 @@ func SearchCommandHandler(session *discordgo.Session, interaction *discordgo.Int case "code": var low, high int var err error - valueRaw := option.StringValue() + valueRaw := strings.TrimSpace(option.StringValue()) // 4 digit code 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 len(match) == 2 { + if len(match) == 2 || len(match[2]) == 0 { high = low } else { high, err = strconv.Atoi(string(match[2]))