From e94ac0cfed3a21e3c0a0737759d849acefb9a43d Mon Sep 17 00:00:00 2001 From: Dalton Date: Fri, 7 Dec 2018 17:21:57 -0800 Subject: [PATCH] remove opportunity for imgur np --- bot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.js b/bot.js index ad636bd..bbc0acc 100644 --- a/bot.js +++ b/bot.js @@ -130,7 +130,8 @@ function imgurRequest(subreddit, page_max) { if (req.responseText !== "Not found") { try { var json = JSON.parse(req.responseText); - returnText = json.data[getRandomInt(0, json.data.length - 1)].link; + let json_data = json.data[getRandomInt(0, json.data.length - 1)]; + if(json_data) { returnText = json_data.link; } } catch (error) { // Ignore the error and let the calling method handle the empty string. }