diff --git a/README.md b/README.md index 0109febd..14000eb4 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 400 +Total: 401 ### Utility: @@ -180,6 +180,7 @@ Total: 400 * **draw-cards:** Draws a random hand of playing cards. * **fact-core:** Responds with a random Fact Core quote. * **fact:** Responds with a random fact. +* **fml:** Responds with a FML quote. (NSFW) * **fortune:** Responds with a random fortune. * **github-zen:** Responds with a random GitHub design philosophy. * **joke:** Responds with a random joke. @@ -742,6 +743,8 @@ here. * wikia ([API](https://www.wikia.com/api/v1/)) - [Flickr](https://www.flickr.com/) * flickr ([API](https://www.flickr.com/services/api/)) +- [FML](https://www.fmylife.com/) + * fml (FML Data) - [Foreign exchange rates API](https://exchangeratesapi.io/) * currency (API) - [Free SVG](https://freesvg.org/) diff --git a/commands/random-res/fml.js b/commands/random-res/fml.js new file mode 100644 index 00000000..adff0832 --- /dev/null +++ b/commands/random-res/fml.js @@ -0,0 +1,34 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); +const cheerio = require('cheerio'); + +module.exports = class FmlCommand extends Command { + constructor(client) { + super(client, { + name: 'fml', + aliases: ['fuck-my-life', 'f-my-life'], + group: 'random-res', + memberName: 'fml', + description: 'Responds with a FML quote.', + nsfw: true, + credit: [ + { + name: 'FML', + url: 'https://www.fmylife.com/', + reason: 'FML Data' + } + ] + }); + } + + async run(msg) { + try { + const { text } = await request.get('http://www.fmylife.com/random'); + const $ = cheerio.load(text, { normalizeWhitespace: true }); + const fml = $('a.article-link').first().text().trim(); + return msg.say(fml); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index f3475194..f8ac07cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "113.14.0", + "version": "113.15.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {