diff --git a/commands/events/horoscope.js b/commands/events/horoscope.js index 04c71509..b150eb09 100644 --- a/commands/events/horoscope.js +++ b/commands/events/horoscope.js @@ -1,6 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const request = require('node-superfetch'); +const cheerio = require('cheerio'); const { list } = require('../../util/Util'); const signs = require('../../assets/json/horoscope'); @@ -27,20 +28,23 @@ module.exports = class HoroscopeCommand extends Command { async run(msg, { sign }) { try { - const { body } = await request.get(`http://theastrologer-api.herokuapp.com/api/horoscope/${sign}/today`); + const horoscope = await this.fetchHoroscope(sign); const embed = new MessageEmbed() .setColor(0x9797FF) - .setTitle(`Horoscope for ${body.sunsign}...`) - .setURL(`https://new.theastrologer.com/${body.sunsign}/`) + .setTitle(`Horoscope for ${sign}...`) + .setURL(`https://new.theastrologer.com/${sign}/`) .setFooter('© Kelli Fox, The Astrologer') .setTimestamp() - .setDescription(body.horoscope) - .addField('❯ Mood', body.meta.mood, true) - .addField('❯ Intensity', body.meta.intensity, true) - .addField('❯ Date', body.date, true); + .setDescription(horoscope); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } } + + async fetchHoroscope(sign) { + const { text } = await request.get(`https://new.theastrologer.com/${sign}/`); + const $ = cheerio.load(text); + return $('#today').find('p').text(); + } }; diff --git a/package.json b/package.json index 896f80a9..78bbf9bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "85.9.1", + "version": "85.9.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -32,6 +32,7 @@ }, "dependencies": { "canvas": "github:automattic/node-canvas", + "cheerio": "1.0.0-rc.2", "common-tags": "^1.8.0", "cowsay": "^1.3.1", "custom-translate": "^2.2.4",