This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+3 -7
View File
@@ -13,12 +13,8 @@ module.exports = class CatCommand extends Command {
}
async run(msg) {
try {
const { body } = await snekfetch
.get('http://random.cat/meow');
return msg.say(body.file);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
const { body } = await snekfetch
.get('http://random.cat/meow');
return msg.say(body.file);
}
};
+3 -7
View File
@@ -12,12 +12,8 @@ module.exports = class DogCommand extends Command {
}
async run(msg) {
try {
const { body } = await snekfetch
.get('https://random.dog/woof.json');
return msg.say(body.url);
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
const { body } = await snekfetch
.get('https://random.dog/woof.json');
return msg.say(body.url);
}
};
+1 -2
View File
@@ -15,7 +15,6 @@ module.exports = class XiaoCommand extends Command {
run(msg) {
const xiao = Math.floor(Math.random() * 10) + 1;
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] });
}
};
+27 -28
View File
@@ -16,11 +16,14 @@ module.exports = class XKCDCommand extends Command {
key: 'type',
prompt: 'Would you like to get the comic for today or random?',
type: 'string',
validate: type => {
if (['today', 'random'].includes(type.toLowerCase())) return true;
return 'Please enter either `today` or `random`';
},
default: 'random'
default: 'random',
validate: (type) => {
if (['today', 'random'].includes(type.toLowerCase())) {
return true;
} else {
return 'Please enter either `today` or `random`';
}
}
}
]
});
@@ -28,29 +31,25 @@ module.exports = class XKCDCommand extends Command {
async run(msg, args) {
const { type } = args;
try {
const current = await snekfetch
.get('https://xkcd.com/info.0.json');
if (type === 'today') {
const embed = new RichEmbed()
.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 {
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 RichEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
const current = await snekfetch
.get('https://xkcd.com/info.0.json');
if (type === 'today') {
const embed = new RichEmbed()
.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 {
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 RichEmbed()
.setTitle(`${body.num} - ${body.title}`)
.setURL(`https://xkcd.com/${body.num}`)
.setImage(body.img)
.setFooter(body.alt);
return msg.embed(embed);
}
}
};