From dbd4069903418297fa5382fa62c9b9bf1b3d3b15 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Fri, 13 Apr 2018 17:59:21 +0000 Subject: [PATCH] Better NASA Image filter --- .gitattributes | 1 + .gitignore | 3 --- commands/search/nasa.js | 11 +++++++---- package.json | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2dfb771f..7487a105 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ *.js text eol=lf *.json text eol=lf *.md text eol=lf +*.yml text eol=lf # Configs and Stuff .gitattributes text eol=lf diff --git a/.gitignore b/.gitignore index 0c65b2e3..b8c3d51e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -# Dependencies node_modules/ package-lock.json - -# Logs logs/ *.log diff --git a/commands/search/nasa.js b/commands/search/nasa.js index 842aa86b..a6c6d015 100644 --- a/commands/search/nasa.js +++ b/commands/search/nasa.js @@ -25,10 +25,13 @@ module.exports = class NASACommand extends Command { try { const { body } = await snekfetch .get('https://images-api.nasa.gov/search') - .query({ q: query }); - const filtered = body.collection.items.filter(item => item.data[0].media_type === 'image'); - if (!filtered.length) return msg.say('Could not find any results.'); - const data = filtered[Math.floor(Math.random() * filtered.length)]; + .query({ + q: query, + media_type: 'image' + }); + const images = body.collection.items; + if (!images.length) return msg.say('Could not find any results.'); + const data = images[Math.floor(Math.random() * images.length)]; return msg.say(shorten(data.data[0].description), { files: [data.links[0].href] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/package.json b/package.json index 469010c1..dfbd7e0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "72.0.0", + "version": "72.0.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {