From f9612f03935f0d67dd95d522af2aff1d6c442884 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 9 Jun 2020 14:18:34 -0400 Subject: [PATCH] AI Food and Artwork --- README.md | 8 +++++++- commands/random-img/ai-art.js | 27 ++++++++++++++++++++++++ commands/random-img/ai-food.js | 35 ++++++++++++++++++++++++++++++++ commands/random-img/ai-person.js | 2 +- package.json | 2 +- 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 commands/random-img/ai-art.js create mode 100644 commands/random-img/ai-food.js diff --git a/README.md b/README.md index cc572cdf..e4274de9 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 467 +Total: 469 ### Utility: @@ -323,6 +323,8 @@ Total: 467 ### Random Image: +* **ai-artwork:** Responds with randomly generated artwork. +* **ai-food:** Responds with a randomly generated food. * **ai-fursona:** Responds with a randomly generated fursona. * **ai-person:** Responds with a randomly generated person. * **ai-waifu:** Responds with a randomly generated waifu. @@ -1399,10 +1401,14 @@ here. * newspaper (API) - [The Onion](https://www.theonion.com/) * the-onion ([RSS Feed](https://www.theonion.com/rss)) +- [This Artwork Does Not Exist](https://thisartworkdoesnotexist.com/) + * ai-artwork (API) - [This Fursona Does Not Exist](https://thisfursonadoesnotexist.com/) * ai-fursona (API) - [This Person Does Not Exist](https://thispersondoesnotexist.com/) * ai-person (API) +- [This Snack Does Not Exist](https://thissnackdoesnotexist.com/) + * ai-food (API) - [This Waifu Does Not Exist](https://www.thiswaifudoesnotexist.net/) * ai-waifu (API) - [Tim's Printables](https://www.timvandevall.com/) diff --git a/commands/random-img/ai-art.js b/commands/random-img/ai-art.js new file mode 100644 index 00000000..919dec10 --- /dev/null +++ b/commands/random-img/ai-art.js @@ -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' }] }); + } +}; diff --git a/commands/random-img/ai-food.js b/commands/random-img/ai-food.js new file mode 100644 index 00000000..4fd91ee0 --- /dev/null +++ b/commands/random-img/ai-food.js @@ -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!`); + } + } +}; diff --git a/commands/random-img/ai-person.js b/commands/random-img/ai-person.js index 10adf687..2f974c68 100644 --- a/commands/random-img/ai-person.js +++ b/commands/random-img/ai-person.js @@ -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' }] }); } }; diff --git a/package.json b/package.json index 5f6fea9e..f97f888e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.11.1", + "version": "116.12.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {