diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index 81b082b..ab0669c 100644 --- a/lorebot/lorebot.go +++ b/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))])