From b55be97ca34e9e5fae882968f07b9bf8367f7741 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 13 Mar 2021 15:25:45 -0500 Subject: [PATCH] Get multiple google results --- commands/search/google.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/commands/search/google.js b/commands/search/google.js index 9b3868fb..ecf5ccfc 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -2,7 +2,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); const cheerio = require('cheerio'); const { URLSearchParams, URL } = require('url'); -const { trimArray } = require('../../util/Util'); module.exports = class GoogleCommand extends Command { constructor(client) { @@ -39,14 +38,14 @@ module.exports = class GoogleCommand extends Command { } async run(msg, { query }) { - let href; + let hrefs; try { - href = await this.search(query, msg.channel.nsfw || false); + hrefs = await this.search(query, msg.channel.nsfw || false); } catch { - href = `http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`; + hrefs = [`http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`]; } - if (!href) return msg.say('Could not find any results.'); - return msg.say(`<${href}>`); + if (!hrefs) return msg.say('Could not find any results.'); + return msg.say(hrefs.map(href => `<${href}>`).join('\n\n')); } async search(query, nsfw) { @@ -74,6 +73,6 @@ module.exports = class GoogleCommand extends Command { } }); if (!links.length) return null; - return links[0]; + return links.slice(0, 3); } };