This commit is contained in:
Daniel Odendahl Jr
2017-09-25 03:14:33 +00:00
parent f2a1b09243
commit e99ec2a8e9
+9 -2
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
module.exports = class RobohashCommand extends Command {
constructor(client) {
@@ -19,7 +20,13 @@ module.exports = class RobohashCommand extends Command {
});
}
run(msg, { text }) {
return msg.say({ files: [`https://robohash.org/${text}`] });
async run(msg, { text }) {
try {
const { body } = await snekfetch
.get(`https://robohash.org/${text}`);
return msg.say({ files: [{ attachment: body, name: 'robohash.png' }] });
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};