Lots of Changes

This commit is contained in:
Daniel Odendahl Jr
2017-09-05 03:07:03 +00:00
parent 56f5c48ff8
commit 1c9b5156e9
19 changed files with 76 additions and 120 deletions
+47
View File
@@ -0,0 +1,47 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class HistoryCommand extends Command {
constructor(client) {
super(client, {
name: 'history',
aliases: ['event', 'today'],
group: 'random-res',
memberName: 'history',
description: 'Responds with an event that occurred today in history, or on a specific day.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'date',
prompt: 'What date do you want events for? Month/Day format.',
type: 'string',
default: ''
}
]
});
}
async run(msg, args) {
const { date } = args;
try {
const { text } = await snekfetch
.get(`http://history.muffinlabs.com/date${date ? `/${date}` : ''}`);
const body = JSON.parse(text);
const events = body.data.Events;
const event = events[Math.floor(Math.random() * events.length)];
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setURL(body.url)
.setTitle(`On this day (${body.date})...`)
.setTimestamp()
.setDescription(`${event.year}: ${event.text}`)
.addField(' See More',
event.links.map(link => `${link.title}: ${link.link.replace(/\)/g, '%29')}`).join('\n'));
return msg.embed(embed);
} catch (err) {
if (err.status === 404 || err.status === 500) return msg.say('Could not find any results.');
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+14 -1
View File
@@ -2,7 +2,20 @@ const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { list } = require('../../structures/Util');
const signs = require('../../assets/json/horoscope');
const signs = [
'capricorn',
'aquarius',
'pisces',
'aries',
'taurus',
'gemini',
'cancer',
'leo',
'virgo',
'libra',
'scorpio',
'sagittarius'
];
module.exports = class HoroscopeCommand extends Command {
constructor(client) {
+3 -2
View File
@@ -23,6 +23,7 @@ module.exports = class SoundboardCommand extends Command {
key: 'sound',
prompt: `What sound would you like to play? Either ${list(sounds, 'or')}.`,
type: 'string',
default: sounds[Math.floor(Math.random() * sounds.length)],
validate: sound => {
if (sounds.includes(sound.toLowerCase())) return true;
return `Invalid sound, please enter either ${list(sounds, 'or')}.`;
@@ -36,9 +37,9 @@ module.exports = class SoundboardCommand extends Command {
async run(msg, args) {
const { sound } = args;
const channel = msg.member.voiceChannel;
if (!channel) return msg.say('Please enter a Voice Channel first.');
if (!channel) return msg.say('Please enter a voice channel first.');
if (!channel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
return msg.say('Missing the `Connect` or `Speak` Permission for the Voice Channel.');
return msg.say('Missing the "Connect" or "Speak" permission for the voice channel.');
}
if (!channel.joinable) return msg.say('Your Voice Channel is not joinable.');
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
+2 -2
View File
@@ -34,7 +34,7 @@ module.exports = class StocksCommand extends Command {
if (body['Error Message']) return msg.say('Could not find any results.');
const data = Object.values(body['Time Series (1min)'])[0];
const embed = new MessageEmbed()
.setTitle(`Stocks for Symbol ${symbol}`)
.setTitle(`Stocks for Symbol ${symbol.toUpperCase()}`)
.setColor(0x9797FF)
.addField(' Open',
`$${data['1. open']}`, true)
@@ -47,7 +47,7 @@ module.exports = class StocksCommand extends Command {
.addField(' Low',
`$${data['3. low']}`, true)
.addField(' Last Updated',
new Date(body['Meta Data']['Last Refreshed']).toDateString(), true);
new Date(body['Meta Data']['3. Last Refreshed']).toDateString(), true);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);