mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 00:06:42 +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();
|
||||
}
|
||||
};
|
||||
|
||||
+2
-1
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user