From e99ec2a8e92fb545af3d7d6aa0339b897b519bd7 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 25 Sep 2017 03:14:33 +0000 Subject: [PATCH] Beep --- commands/image-edit/robohash.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commands/image-edit/robohash.js b/commands/image-edit/robohash.js index ad939e17..7421d588 100644 --- a/commands/image-edit/robohash.js +++ b/commands/image-edit/robohash.js @@ -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!`); + } } };