mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 16:19:12 +02:00
Filter only valid images
This commit is contained in:
@@ -26,7 +26,7 @@ module.exports = class ImgurCommand extends Command {
|
|||||||
.get('https://api.imgur.com/3/gallery/search')
|
.get('https://api.imgur.com/3/gallery/search')
|
||||||
.query({ q: query })
|
.query({ q: query })
|
||||||
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
|
.set({ Authorization: `Client-ID ${IMGUR_KEY}` });
|
||||||
const images = msg.channel.nsfw ? body.data : body.data.filter(image => !image.nsfw);
|
const images = body.data.filter(image => image.images && (msg.channel.nsfw ? true : !image.nsfw));
|
||||||
if (!images.length) return msg.say('Could not find any results.');
|
if (!images.length) return msg.say('Could not find any results.');
|
||||||
return msg.say(images[Math.floor(Math.random() * images.length)].images[0].link);
|
return msg.say(images[Math.floor(Math.random() * images.length)].images[0].link);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user