mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Fix horoscope
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user