Horoscope

This commit is contained in:
Daniel Odendahl Jr
2017-05-16 12:51:35 +00:00
parent acf499fabe
commit 4fe49fe24a
5 changed files with 74 additions and 4 deletions
+14
View File
@@ -0,0 +1,14 @@
[
"capricorn",
"aquarius",
"pisces",
"aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius"
]
+54
View File
@@ -0,0 +1,54 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const signs = require('../../assets/json/horoscope');
module.exports = class HoroscopeCommand extends Command {
constructor(client) {
super(client, {
name: 'horoscope',
group: 'random',
memberName: 'horoscope',
description: 'Gives the horoscope for today for a particular sign.',
details: signs.join(', '),
args: [
{
key: 'sign',
prompt: 'Which sign would you like to get the horoscope for?',
type: 'string',
validate: sign => {
if (signs.includes(sign.toLowerCase())) return true;
return 'Invalid sign. Use `help horoscope` for a list of signs';
},
parse: sign => sign.toLowerCase()
}
]
});
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.');
const { sign } = args;
try {
const { text } = await snekfetch
.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today`);
const body = JSON.parse(text);
const embed = new RichEmbed()
.setColor()
.setTitle(`Horoscope for ${body.sunsign}...`)
.setTimestamp()
.setDescription(body.horoscope)
.addField('Mood',
body.meta.mood, true)
.addField('Intensity',
body.meta.intensity, true)
.addField('Date',
body.date);
return msg.embed(embed);
} catch (err) {
return msg.say('An Error Occurred.');
}
}
};
+4 -4
View File
@@ -19,13 +19,13 @@ module.exports = class TodayCommand extends Command {
try { try {
const { text } = await snekfetch const { text } = await snekfetch
.get('http://history.muffinlabs.com/date'); .get('http://history.muffinlabs.com/date');
const parsed = JSON.parse(text); const body = JSON.parse(text);
const events = parsed.data.Events; const events = body.data.Events;
const event = events[Math.floor(Math.random() * events.length)]; const event = events[Math.floor(Math.random() * events.length)];
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(0x9797FF) .setColor(0x9797FF)
.setURL(parsed.url) .setURL(body.url)
.setTitle(`On this day (${parsed.date})...`) .setTitle(`On this day (${body.date})...`)
.setTimestamp() .setTimestamp()
.setDescription(`${event.year}: ${event.text}`); .setDescription(`${event.year}: ${event.text}`);
return msg.embed(embed); return msg.embed(embed);
+1
View File
@@ -30,6 +30,7 @@
<li>Would you rather questions!</li> <li>Would you rather questions!</li>
<li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li> <li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li>
<li>8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!</li> <li>8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!</li>
<li>Horoscopes!</li>
<li>Waifu and Ship Rating!</li> <li>Waifu and Ship Rating!</li>
<li>Random Roasts, Fortunes, and Compliments!</li> <li>Random Roasts, Fortunes, and Compliments!</li>
<li>Random Fact Core Quotes!</li> <li>Random Fact Core Quotes!</li>
+1
View File
@@ -25,6 +25,7 @@
<li>Would you rather questions!</li> <li>Would you rather questions!</li>
<li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li> <li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li>
<li>8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!</li> <li>8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!</li>
<li>Horoscopes!</li>
<li>Waifu and Ship Rating!</li> <li>Waifu and Ship Rating!</li>
<li>Random Roasts, Fortunes, and Compliments!</li> <li>Random Roasts, Fortunes, and Compliments!</li>
<li>Random Fact Core Quotes!</li> <li>Random Fact Core Quotes!</li>