From e95307eef66a9314fa99548643733bd47ce7e170 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 22 May 2020 15:48:59 -0400 Subject: [PATCH] Lorem Picsum Command --- README.md | 3 ++ commands/random-img/lorem-picsum.js | 55 +++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 commands/random-img/lorem-picsum.js diff --git a/README.md b/README.md index 7177f1d6..47b5cff3 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,7 @@ Total: 433 * **karen:** Responds with a random image of Karen. * **lando:** Responds with a random image of Lando Calrissian. * **light-novel-cover:** Responds with a randomly generated Light Novel cover. (NSFW) +* **lorem-picsum:** Responds with a random image of a certain size. * **meme:** Responds with a random meme. * **potato:** Responds with a random potato image. * **shiba:** Responds with a random image of a Shiba Inu. @@ -1071,6 +1072,8 @@ here. * light-novel-cover (API) - [LN title generator](https://salty-salty-studios.com/shiz/ln.php) * light-novel-title (API) +- [Lorem Picsum](https://picsum.photos/) + * lorem-picsum (API) - [LoveToKnow](https://www.lovetoknow.com/) * horse-race ([Horse Name Data](https://horses.lovetoknow.com/horse-names/funny-horse-names)) - [Mad Libs](http://www.madlibs.com/) diff --git a/commands/random-img/lorem-picsum.js b/commands/random-img/lorem-picsum.js new file mode 100644 index 00000000..bcbc85ad --- /dev/null +++ b/commands/random-img/lorem-picsum.js @@ -0,0 +1,55 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class LoremPicsumCommand extends Command { + constructor(client) { + super(client, { + name: 'lorem-picsum', + aliases: ['lorem-p', 'picsum'], + group: 'random-img', + memberName: 'lorem-picsum', + description: 'Responds with a random image of a certain size.', + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Lorem Picsum', + url: 'https://picsum.photos/', + reason: 'API' + } + ], + args: [ + { + key: 'width', + prompt: 'What do you want the width of the image to be?', + type: 'integer', + max: 2000, + min: 10 + }, + { + key: 'height', + prompt: 'What do you want the height of the image to be?', + type: 'integer', + max: 2000, + min: 10 + }, + { + key: 'seed', + prompt: 'What seed do you want to provide for image generation?', + type: 'string', + default: '', + max: 100, + parse: seed => encodeURIComponent(seed) + } + ] + }); + } + + async run(msg, { width, height, seed }) { + try { + const { body } = await request.get(`https://picsum.photos/${seed ? `seed/${seed}/` : ''}${width}/${height}`); + return msg.say({ files: [{ attachment: body, name: `${width}x${height}.jpg` }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 54f5a458..05235020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.21.1", + "version": "114.22.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {