Quote, Random in Gelbooru and Rule34, Reorder Groups

This commit is contained in:
Daniel Odendahl Jr
2017-07-25 21:31:14 +00:00
parent 0d51d7ca78
commit 4ee179f359
12 changed files with 54 additions and 20 deletions
-58
View File
@@ -1,58 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class TodayCommand extends Command {
constructor(client) {
super(client, {
name: 'today',
aliases: ['event'],
group: 'random',
memberName: 'today',
description: 'Responds with an event that occurred today in history, or on a specific day.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'month',
prompt: 'Which month do you want events for?',
type: 'integer',
default: '',
validate: (month) => {
if (month < 13 && month > 0) return true;
else return 'Please enter a valid month.';
}
},
{
key: 'day',
prompt: 'Which day do you want events for?',
type: 'integer',
default: '',
validate: (day) => {
if (day < 32 && day > 0) return true;
else return 'Please enter a valid day.';
}
}
]
});
}
async run(msg, args) {
const { month, day } = args;
try {
const { text } = await snekfetch
.get(`http://history.muffinlabs.com/date${month && day ? `/${month}/${day}` : ''}`);
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}`);
return msg.embed(embed);
} catch (err) {
return msg.say(`An error occurred: \`${err.message}\`. You likely entered an invalid date.`);
}
}
};
-27
View File
@@ -1,27 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class WouldYouRatherCommand extends Command {
constructor(client) {
super(client, {
name: 'would-you-rather',
aliases: ['wy-rather'],
group: 'random',
memberName: 'would-you-rather',
description: 'Responds with a random would you rather question.',
clientPermissions: ['EMBED_LINKS']
});
}
async run(msg) {
const { body } = await snekfetch
.get('http://www.rrrather.com/botapi');
const embed = new MessageEmbed()
.setTitle(`${body.title}...`)
.setURL(body.link)
.setColor(0x9797FF)
.setDescription(`${body.choicea} OR ${body.choiceb}?`);
return msg.embed(embed);
}
};
+60
View File
@@ -0,0 +1,60 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class XKCDCommand extends Command {
constructor(client) {
super(client, {
name: 'xkcd',
aliases: ['kcd'],
group: 'random',
memberName: 'xkcd',
description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'type',
prompt: 'Please enter either a specific comic number, today, or random.',
type: 'string',
default: 'random',
parse: (type) => type.toLowerCase()
}
]
});
}
async run(msg, args) {
const { type } = args;
const current = await snekfetch
.get('https://xkcd.com/info.0.json');
if (type === 'today') {
const embed = new MessageEmbed()
.setTitle(`${current.body.num} - ${current.body.title}`)
.setURL(`https://xkcd.com/${current.body.num}`)
.setImage(current.body.img)
.setFooter(current.body.alt);
return msg.embed(embed);
} else 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`);
const embed = new MessageEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setURL(`https://xkcd.com/${body.num}`)
.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}`)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
}
};