mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
Fix: Intn Panic when the len is 0 (#617)
This commit is contained in:
parent
cc26eb1332
commit
e1591c44b6
@ -44,6 +44,9 @@ func init() {
|
||||
return "", err
|
||||
}
|
||||
arr := gjson.Get(helper.BytesToString(data), "data.data").Array()
|
||||
if len(arr) == 0 {
|
||||
return "", errors.New("data is empty")
|
||||
}
|
||||
pic := arr[rand.Intn(len(arr))]
|
||||
return pic.String(), nil
|
||||
}, web.GetData, time.Minute)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user