diff --git a/assets/json/horoscope.json b/assets/json/horoscope.json new file mode 100644 index 00000000..121b02e8 --- /dev/null +++ b/assets/json/horoscope.json @@ -0,0 +1,14 @@ +[ + "capricorn", + "aquarius", + "pisces", + "aries", + "taurus", + "gemini", + "cancer", + "leo", + "virgo", + "libra", + "scorpio", + "sagittarius" +] diff --git a/commands/random/horoscope.js b/commands/random/horoscope.js new file mode 100644 index 00000000..a13b5120 --- /dev/null +++ b/commands/random/horoscope.js @@ -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.'); + } + } +}; diff --git a/commands/random/today.js b/commands/random/today.js index 079f61e1..4711dc87 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -19,13 +19,13 @@ module.exports = class TodayCommand extends Command { try { const { text } = await snekfetch .get('http://history.muffinlabs.com/date'); - const parsed = JSON.parse(text); - const events = parsed.data.Events; + const body = JSON.parse(text); + const events = body.data.Events; const event = events[Math.floor(Math.random() * events.length)]; const embed = new RichEmbed() .setColor(0x9797FF) - .setURL(parsed.url) - .setTitle(`On this day (${parsed.date})...`) + .setURL(body.url) + .setTitle(`On this day (${body.date})...`) .setTimestamp() .setDescription(`${event.year}: ${event.text}`); return msg.embed(embed); diff --git a/html/carbonfeat.html b/html/carbonfeat.html index c46fe281..7871cae6 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -30,6 +30,7 @@
  • Would you rather questions!
  • Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!
  • 8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!
  • +
  • Horoscopes!
  • Waifu and Ship Rating!
  • Random Roasts, Fortunes, and Compliments!
  • Random Fact Core Quotes!
  • diff --git a/html/discordbots.html b/html/discordbots.html index cb9f024a..a902e59e 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -25,6 +25,7 @@
  • Would you rather questions!
  • Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!
  • 8 Ball, Magic Conch, Coin Flip, Choose, Random Member, and Roll!
  • +
  • Horoscopes!
  • Waifu and Ship Rating!
  • Random Roasts, Fortunes, and Compliments!
  • Random Fact Core Quotes!