From 93df647437ad2855785a4515f9b05bc570a6aa30 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 4 Dec 2017 18:51:26 +0000 Subject: [PATCH] Fix safebooru --- commands/search/safebooru.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/search/safebooru.js b/commands/search/safebooru.js index 2a06fc51..250f014d 100644 --- a/commands/search/safebooru.js +++ b/commands/search/safebooru.js @@ -22,7 +22,7 @@ module.exports = class SafebooruCommand extends Command { async run(msg, { query }) { try { - const { body } = await snekfetch + const { text } = await snekfetch .get('https://safebooru.org/index.php') .query({ page: 'dapi', @@ -32,7 +32,8 @@ module.exports = class SafebooruCommand extends Command { tags: query, limit: 200 }); - if (!body) return msg.say('Could not find any results.'); + if (!text) return msg.say('Could not find any results.'); + const body = JSON.parse(text); const data = body[Math.floor(Math.random() * body.length)]; return msg.say(`https://safebooru.org/images/${data.directory}/${data.image}`); } catch (err) {