diff --git a/README.md b/README.md index ddb7f5b9..fa327aa1 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Xiao is a Discord bot coded in JavaScript with ## Commands -Total: 356 +Total: 357 ### Utility: @@ -229,6 +229,7 @@ Total: 356 * **define:** Defines a word. * **derpibooru:** Responds with an image from Derpibooru. * **deviantart:** Responds with an image from a DeviantArt section, with optional query. +* **frinkiac:** Input a line from the Simpsons to get the episode/season. * **giphy:** Searches Giphy for your query. * **github:** Responds with information on a GitHub repository. * **google-autofill:** Responds with a list of the Google Autofill results for a particular query. @@ -619,6 +620,8 @@ here. * currency (API) - [freeiconspng.com](https://www.freeiconspng.com/) * hat ([Birthday Hat Image](https://www.freeiconspng.com/img/43917)) +- [Frinkiac](https://frinkiac.com/) + * frinkiac (API) - [Gallery Yopriceville](https://gallery.yopriceville.com/) * hat ([Pilgrim Hat Image](https://gallery.yopriceville.com/Free-Clipart-Pictures/Thanksgiving-PNG/Transparent_Brown_Pilgrim_Hat_PNG_Clipart)) - [gautamkrishnar](https://github.com/gautamkrishnar/) diff --git a/commands/search/frinkiac.js b/commands/search/frinkiac.js new file mode 100644 index 00000000..c2dfeafd --- /dev/null +++ b/commands/search/frinkiac.js @@ -0,0 +1,48 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); +const moment = require('moment'); + +module.exports = class FrinkiacCommand extends Command { + constructor(client) { + super(client, { + name: 'frinkiac', + aliases: ['the-simpsons', 'simpsons', 'simpson'], + group: 'search', + memberName: 'frinkiac', + description: 'Input a line from the Simpsons to get the episode/season.', + credit: [ + { + name: 'Frinkiac', + url: 'https://frinkiac.com/', + reason: 'API' + } + ], + args: [ + { + key: 'query', + prompt: 'What line would you like to look up?', + type: 'string' + } + ] + }); + } + + async run(msg, { query }) { + try { + const { body } = await request + .get('https://frinkiac.com/api/search') + .query({ q: query }); + if (!body.length) return msg.say('Could not find any results.'); + const data = body[0]; + const url = `https://frinkiac.com/caption/${data.Episode}/${data.Timestamp}`; + const [, season, episode] = data.Episode.match(/S([0-9]+)E([0-9]+)/i); + const time = moment.duration(data.Timestamp).format(); + return msg.say( + `I think this is from **Season ${season} Episode ${episode} @ ${time}**.`, + { files: [`https://frinkiac.com/img/${data.Episode}/${data.Timestamp}.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 2bd875c2..dbe88da0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "110.3.0", + "version": "110.4.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {