From 50920197896736f2c14119d6349ce4bcaca4272b Mon Sep 17 00:00:00 2001 From: dragonfire535 Date: Mon, 13 Mar 2017 09:07:39 -0400 Subject: [PATCH] Fix bug --- commands/search/google.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/commands/search/google.js b/commands/search/google.js index 581e9d7e..9178acce 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -19,20 +19,24 @@ class GoogleCommand extends commando.Command { } console.log("[Command] " + message.content); let searchQuery = message.content.split(" ").slice(1).join(" "); - google.resultsPerPage = 2 - google(searchQuery, function (err, res) { - if (err) message.channel.sendMessage(':x: An Error Occurred! Try again later!'); - let link = res.links; - if(link === undefined) { - message.channel.sendMessage(':x: Error! No Results Found!'); - } else { - if(link[0].href === undefined) { + if(searchQuery === "") { + message.channel.sendMessage(':x: Error! I cannot search google for nothing!'); + } else { + google.resultsPerPage = 2 + google(searchQuery, function (err, res) { + if (err) message.channel.sendMessage(':x: An Error Occurred! Try again later!'); + let link = res.links; + if(link === undefined) { message.channel.sendMessage(':x: Error! No Results Found!'); } else { - message.channel.sendMessage(link[0].href).catch(error => message.channel.sendMessage(':x: An Error Occurred! Try again later!')); + if(link[0].href === undefined) { + message.channel.sendMessage(':x: Error! No Results Found!'); + } else { + message.channel.sendMessage(link[0].href).catch(error => message.channel.sendMessage(':x: An Error Occurred! Try again later!')); + } } - } - }); + }); + } } }