From ce990f856598017fc13d48a0ff4a2d8b955b7a3d Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 13 Mar 2021 15:30:04 -0500 Subject: [PATCH] Add titles to google results --- commands/search/google.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/search/google.js b/commands/search/google.js index ecf5ccfc..e1767f17 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -42,10 +42,10 @@ module.exports = class GoogleCommand extends Command { try { hrefs = await this.search(query, msg.channel.nsfw || false); } catch { - hrefs = [`http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`]; + hrefs = [{ href: `http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`, title: 'LMGTFY' }]; } if (!hrefs) return msg.say('Could not find any results.'); - return msg.say(hrefs.map(href => `<${href}>`).join('\n\n')); + return msg.say(hrefs.map(href => `${href.title}\n<${href.href}>`).join('\n\n')); } async search(query, nsfw) { @@ -67,7 +67,7 @@ module.exports = class GoogleCommand extends Command { const params = new URLSearchParams(href); const url = new URL(params.get('url')); if (nsfw || !this.client.adultSiteList.includes(url.host)) { - links.push(url.href); + links.push({ href: url.href, title: $(h3).text() }); } } }