This commit is contained in:
Daniel Odendahl Jr
2017-09-26 14:09:05 +00:00
parent 55e615b5b4
commit da63a908e7
14 changed files with 228 additions and 103 deletions
+3 -10
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const facts = require('../../assets/json/cat-fact');
module.exports = class CatFactCommand extends Command {
constructor(client) {
@@ -12,14 +12,7 @@ module.exports = class CatFactCommand extends Command {
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('https://catfact.ninja/fact')
.query({ max_length: 2000 });
return msg.say(body.fact);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
run(msg) {
return msg.say(facts[Math.floor(Math.random() * facts.length)]);
}
};
+3 -9
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const facts = require('../../assets/json/dog-fact');
module.exports = class DogFactCommand extends Command {
constructor(client) {
@@ -12,13 +12,7 @@ module.exports = class DogFactCommand extends Command {
});
}
async run(msg) {
try {
const { body } = await snekfetch
.get('https://dog-api.kinduff.com/api/facts');
return msg.say(body.facts[0]);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
run(msg) {
return msg.say(facts[Math.floor(Math.random() * facts.length)]);
}
};
+1
View File
@@ -7,6 +7,7 @@ module.exports = class NameCommand extends Command {
constructor(client) {
super(client, {
name: 'name',
aliases: ['random-person'],
group: 'random-res',
memberName: 'name',
description: 'Responds with a random name, with the gender of your choice.',
-68
View File
@@ -1,68 +0,0 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
const { list } = require('../../structures/Util');
const genders = ['male', 'female', 'both'];
module.exports = class RandomPersonCommand extends Command {
constructor(client) {
super(client, {
name: 'random-person',
group: 'random-res',
memberName: 'random-person',
description: 'Responds with a randomly generated person.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'gender',
prompt: `What gender do you want to generate a name for? Either ${list(genders, 'or')}.`,
type: 'string',
default: 'both'
}
]
});
}
async run(msg, { gender }) {
try {
const { body } = await snekfetch
.get('https://randomuser.me/api/')
.query({
gender,
nat: 'us,gb,au',
noinfo: ''
});
const data = body.results[0];
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setThumbnail(data.picture.large)
.addField(' First Name',
data.name.first.toUpperCase(), true)
.addField(' Last Name',
data.name.last.toUpperCase(), true)
.addField(' Title',
`${data.name.title.toUpperCase()}.`, true)
.addField(' Gender',
data.gender.toUpperCase(), true)
.addField(' Username',
data.login.username, true)
.addField(' Password',
data.login.password, true)
.addField(' Phone',
data.phone, true)
.addField(' Cell',
data.cell, true)
.addField(' Birthday',
new Date(data.dob).toDateString(), true)
.addField(' Address',
stripIndents`
${data.location.street.toUpperCase()}
${data.location.city.toUpperCase()}, ${data.location.state.toUpperCase()} ${data.location.postcode}
`);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};