mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 06:10:49 +02:00
Better NASA Image filter
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
@@ -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!`);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "72.0.0",
|
||||
"version": "72.0.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user