Fix safebooru

This commit is contained in:
Daniel Odendahl Jr
2017-12-04 18:51:26 +00:00
parent d10987abd8
commit 93df647437
+3 -2
View File
@@ -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) {