mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Use NSFW AI in flickr
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { isImageNSFW } = require('../../util/Util');
|
||||
const { FLICKR_KEY } = process.env;
|
||||
|
||||
module.exports = class FlickrCommand extends Command {
|
||||
@@ -8,8 +9,7 @@ module.exports = class FlickrCommand extends Command {
|
||||
name: 'flickr',
|
||||
group: 'search',
|
||||
memberName: 'flickr',
|
||||
description: 'Searches Flickr for your query... Maybe.',
|
||||
nsfw: true,
|
||||
description: 'Searches Flickr for your query.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Flickr',
|
||||
@@ -41,7 +41,13 @@ module.exports = class FlickrCommand extends Command {
|
||||
});
|
||||
if (!body.photos.photo.length) return msg.say('Could not find any results.');
|
||||
const data = body.photos.photo[Math.floor(Math.random() * body.photos.photo.length)];
|
||||
return msg.say(`https://farm${data.farm}.staticflickr.com/${data.server}/${data.id}_${data.secret}.jpg`);
|
||||
const url = `https://farm${data.farm}.staticflickr.com/${data.server}/${data.id}_${data.secret}.jpg`;
|
||||
if (!msg.channel.nsfw) {
|
||||
const { body: imageBody } = await request.get(url);
|
||||
const aiDetect = await isImageNSFW(this.client.nsfwModel, imageBody);
|
||||
if (aiDetect) return msg.reply('Found an NSFW image. Sorry, please try again.');
|
||||
}
|
||||
return msg.say(url);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user