From 4623598d4d5366c9c949609781551e0fbfc5c0fe Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 26 Jan 2020 21:38:48 -0500 Subject: [PATCH] Light Novel Cover Command --- README.md | 5 ++++- commands/nsfw/light-novel-cover.js | 36 ++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 commands/nsfw/light-novel-cover.js diff --git a/README.md b/README.md index 1bf2e458..9984e588 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Xiao is a Discord bot coded in JavaScript with ## Commands -Total: 355 +Total: 356 ### Utility: @@ -472,6 +472,7 @@ Total: 355 * **danbooru:** Responds with an image from Danbooru, with optional query. * **dick:** Determines your dick size. * **flickr:** Searches Flickr for your query... Maybe. +* **light-novel-cover:** Responds with a randomly generated Light Novel cover. ### Other: @@ -747,6 +748,8 @@ here. - [LMGTFY](https://lmgtfy.com/) * google (API) * lmgtfy (API) +- [LN cover generator](https://salty-salty-studios.com/shiz/lncovers.php) + * light-novel-cover (API) - [LN title generator](https://salty-salty-studios.com/shiz/ln.php) * light-novel-title (API) - [MangaGamer.com](https://www.mangagamer.com/) diff --git a/commands/nsfw/light-novel-cover.js b/commands/nsfw/light-novel-cover.js new file mode 100644 index 00000000..d8f3d0b4 --- /dev/null +++ b/commands/nsfw/light-novel-cover.js @@ -0,0 +1,36 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); +const cheerio = require('cheerio'); + +module.exports = class LightNovelCoverCommand extends Command { + constructor(client) { + super(client, { + name: 'light-novel-cover', + aliases: ['ln-cover'], + group: 'nsfw', + memberName: 'light-novel-cover', + description: 'Responds with a randomly generated Light Novel cover.', + nsfw: true, + credit: [ + { + name: 'LN cover generator', + url: 'https://salty-salty-studios.com/shiz/lncovers.php', + reason: 'API' + } + ] + }); + } + + async run(msg) { + try { + const { text } = await request.get('https://salty-salty-studios.com/shiz/lncovers.php'); + const $ = cheerio.load(text); + const cover = $('img').first(); + return msg.channel.send(cover.attr('alt'), { + files: [`https://salty-salty-studios.com/shiz/${cover.attr('src')}`] + }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index cf4c8da6..2bd875c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "110.2.1", + "version": "110.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {