mirror of
https://github.com/Xevion/banner.git
synced 2025-12-10 22:06:34 -06:00
Trim raw string code value, check length of 2nd group before Atoi
This commit is contained in:
@@ -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]))
|
||||||
|
|||||||
Reference in New Issue
Block a user