AI Food and Artwork

This commit is contained in:
Dragon Fire
2020-06-09 14:18:34 -04:00
parent 06fe2a0f49
commit f9612f0393
5 changed files with 71 additions and 3 deletions
+27
View File
@@ -0,0 +1,27 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
module.exports = class AiArtworkCommand extends Command {
constructor(client) {
super(client, {
name: 'ai-artwork',
aliases: ['this-artwork-does-not-exist', 'art', 'artwork', 'ai-art', 'this-art-does-not-exist'],
group: 'random-img',
memberName: 'ai-artwork',
description: 'Responds with randomly generated artwork.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'This Artwork Does Not Exist',
url: 'https://thisartworkdoesnotexist.com/',
reason: 'API'
}
]
});
}
async run(msg) {
const { body } = await request.get('https://thisartworkdoesnotexist.com/artwork');
return msg.say('AI-Generated Artwork', { files: [{ attachment: body, name: 'ai-artwork.jpg' }] });
}
};
+35
View File
@@ -0,0 +1,35 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const cheerio = require('cheerio');
module.exports = class AiFoodCommand extends Command {
constructor(client) {
super(client, {
name: 'ai-food',
aliases: ['this-food-does-not-exist', 'this-snack-does-not-exist', 'ai-snack', 'food', 'snack'],
group: 'random-img',
memberName: 'ai-food',
description: 'Responds with a randomly generated food.',
nsfw: true,
credit: [
{
name: 'This Snack Does Not Exist',
url: 'https://thissnackdoesnotexist.com/',
reason: 'API'
}
]
});
}
async run(msg) {
try {
const { text } = await request.get('https://thissnackdoesnotexist.com/');
const $ = cheerio.load(text);
const img = $('div[class="Absolute-Center"]').first().attr('style').match(/background-image:url\((.+)\);/i)[1];
const name = $('h1[class="snack-description"]').first().text();
return msg.say(`AI-Generated Food: ${name}`, { files: [{ attachment: img, name: 'ai-food.jpg' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -22,6 +22,6 @@ module.exports = class AiPersonCommand extends Command {
async run(msg) {
const { body } = await request.get('https://thispersondoesnotexist.com/image');
return msg.say('AI-Generated Person', { files: [{ attachment: body, name: 'this-person-does-not-exist.jpg' }] });
return msg.say('AI-Generated Person', { files: [{ attachment: body, name: 'ai-person.jpg' }] });
}
};