This commit is contained in:
Daniel Odendahl Jr
2017-09-27 16:49:37 +00:00
parent 9f1b9688ae
commit 8a70e44902
16 changed files with 88 additions and 18 deletions
+10 -2
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { FLICKR_KEY } = process.env;
@@ -10,6 +11,7 @@ module.exports = class FlickrCommand extends Command {
group: 'search',
memberName: 'flickr',
description: 'Searches Flickr for your query.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
@@ -32,8 +34,14 @@ module.exports = class FlickrCommand extends Command {
nojsoncallback: true
});
if (!body.photos.photo.length) return msg.say('Could not find any results.');
const photo = body.photos.photo[Math.floor(Math.random() * body.photos.photo.length)];
return msg.say(`https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.secret}.jpg`);
const data = body.photos.photo[Math.floor(Math.random() * body.photos.photo.length)];
const embed = new MessageEmbed()
.setAuthor('Flickr', 'https://i.imgur.com/8QPPlV9.png')
.setColor(0x0059D4)
.setImage(`https://farm${data.farm}.staticflickr.com/${data.server}/${data.id}_${data.secret}.jpg`)
.setTitle(data.title)
.setURL(`https://www.flickr.com/photos/${data.owner}/${data.id}`);
return msg.embed(embed);
} catch (err) {
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}