Browse Source

Add error checking to not trace on empty db

develop
Matthew Faltys 7 years ago
parent
commit
4f01524e98
  1. 14
      lorebot/lorebot.go

14
lorebot/lorebot.go

@ -361,6 +361,12 @@ func rnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clien
glogger.Error.Println(err)
println(err)
}
// if the array is empty, exit early
if len(command) <= 0 {
return
}
// pick a random one
rand.Seed(time.Now().UnixNano())
rngLore := fmt.Sprint(command[rand.Intn(len(command))])
@ -482,11 +488,17 @@ func rmdubshandler(rtm *slack.RTM, ev *slack.MessageEvent, rmContent string, red
func dubshandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) {
// aka index:command:added
newType := fmt.Sprintf("index:dubs")
//command, err := botfunc.Query(newType, redisClient)
command, err := loreQuery(newType, redisClient)
if err != nil {
glogger.Error.Println(err)
}
// if the array is empty, exit early
if len(command) <= 0 {
return
}
// pick a random one
rand.Seed(time.Now().UnixNano())
rngDubs := fmt.Sprint(command[rand.Intn(len(command))])

Loading…
Cancel
Save