Lots of Changes

This commit is contained in:
Daniel Odendahl Jr
2017-08-26 01:20:43 +00:00
parent d2008c749d
commit 56e72f7509
78 changed files with 393 additions and 389 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
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');
module.exports = class HoroscopeCommand extends Command {
@@ -15,11 +16,11 @@ module.exports = class HoroscopeCommand extends Command {
args: [
{
key: 'sign',
prompt: 'Which sign would you like to get the horoscope for?',
prompt: `Which sign would you like to get the horoscope for? Either ${list(signs, 'or')}.`,
type: 'string',
validate: sign => {
if (signs.includes(sign.toLowerCase())) return true;
return 'Invalid sign. Use `help horoscope` for a list of signs.';
return `Invalid sign, please enter either ${list(signs, 'or')}.`;
},
parse: sign => sign.toLowerCase()
}
+6 -6
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const sounds = require('../../assets/json/soundboard');
const { list } = require('../../structures/Util');
const path = require('path');
const sounds = ['airhorn', 'cat', 'dun-dun-dun', 'pikachu', 'space'];
module.exports = class SoundboardCommand extends Command {
constructor(client) {
@@ -20,14 +21,13 @@ module.exports = class SoundboardCommand extends Command {
args: [
{
key: 'sound',
prompt: 'What sound would you like to play?',
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. Use `help soundboard` for a list of sounds.';
return `Invalid sound, please enter either ${list(sounds, 'or')}.`;
},
parse: sound => path.join(__dirname, '..', '..', 'assets', 'sounds', `${sound.toLowerCase()}.mp3`)
parse: sound => sound.toLowerCase()
}
]
});
@@ -44,7 +44,7 @@ module.exports = class SoundboardCommand extends Command {
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
const connection = await channel.join();
await msg.react('🔊');
const dispatcher = connection.playFile(sound, { volume: 0.25 });
const dispatcher = connection.playFile(path.join(__dirname, '..', '..', 'assets', 'sounds', `${sound}.mp3`));
dispatcher.once('end', () => {
channel.leave();
msg.react('✅');
+6 -5
View File
@@ -6,6 +6,7 @@ module.exports = class StrawpollCommand extends Command {
constructor(client) {
super(client, {
name: 'strawpoll',
aliases: ['poll'],
group: 'random',
memberName: 'strawpoll',
description: 'Creates a Strawpoll from the options you provide.',
@@ -16,7 +17,7 @@ module.exports = class StrawpollCommand extends Command {
type: 'string',
validate: title => {
if (title.length < 200) return true;
return 'Title must be under 200 characters.';
return 'Please keep the title under 200 characters.';
}
},
{
@@ -26,7 +27,7 @@ module.exports = class StrawpollCommand extends Command {
infinite: true,
validate: choice => {
if (choice.length < 140) return true;
return 'Choices must be under 140 characters each.';
return 'Please keep choices under 140 characters each.';
}
}
]
@@ -35,14 +36,14 @@ module.exports = class StrawpollCommand extends Command {
async run(msg, args) {
const { title, options } = args;
if (options.length < 2) return msg.say('You provided less than two choices.');
if (options.length > 31) return msg.say('You provided more than thirty choices.');
if (options.length < 2) return msg.say('Please provide more than one choice.');
if (options.length > 31) return msg.say('Please provide thirty or less choices.');
const { body } = await snekfetch
.post('https://strawpoll.me/api/v2/polls')
.send({ title, options });
return msg.say(stripIndents`
${body.title}
http://strawpoll.me/${body.id}
http://www.strawpoll.me/${body.id}
`);
}
};
+13 -13
View File
@@ -35,7 +35,8 @@ module.exports = class XKCDCommand extends Command {
.setImage(current.body.img)
.setFooter(current.body.alt);
return msg.embed(embed);
} else if (type === 'random') {
}
if (type === 'random') {
const random = Math.floor(Math.random() * current.body.num) + 1;
const { body } = await snekfetch
.get(`https://xkcd.com/${random}/info.0.json`);
@@ -46,18 +47,17 @@ module.exports = class XKCDCommand extends Command {
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
} else {
const choice = parseInt(type, 10);
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Invalid Number.');
const { body } = await snekfetch
.get(`https://xkcd.com/${choice}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setColor(0x9797FF)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
const choice = parseInt(type, 10);
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Invalid number.');
const { body } = await snekfetch
.get(`https://xkcd.com/${choice}/info.0.json`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setColor(0x9797FF)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
};