From 48c69922ad4322161c79ba1005016cab870f809c Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Fri, 12 Oct 2018 00:56:27 +0000 Subject: [PATCH] Fix --- commands/search/mayo-clinic.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/commands/search/mayo-clinic.js b/commands/search/mayo-clinic.js index c9476755..6a46167e 100644 --- a/commands/search/mayo-clinic.js +++ b/commands/search/mayo-clinic.js @@ -28,6 +28,7 @@ module.exports = class MayoClinicCommand extends Command { const location = await this.search(query); if (!location) return msg.say('Could not find any results.'); const data = await this.fetchDisease(location); + if (typeof data === 'string') return msg.say(`I found a match, but it\'s not a disease: ${data}`); const embed = new MessageEmbed() .setColor(0x0044B3) .setAuthor('Mayo Clinic', 'https://i.imgur.com/9zdulOS.jpg', 'https://www.mayoclinic.org/') @@ -53,10 +54,14 @@ module.exports = class MayoClinicCommand extends Command { async fetchDisease(location) { const { text } = await request.get(location); const $ = cheerio.load(text); - return { - name: $('h1').first().text().trim(), - url: location, - description: $('h2').first().next().text() - }; + const overview = $('h2').first().text() === 'Overview'; + if (overview) { + return { + name: $('h1').first().text().trim(), + url: location, + description: overview.next().text() + }; + } + return location; } };