From 5f8719914e8eb8d3733aa76f58c1bf5e17a36f1b Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 7 Sep 2020 16:41:10 -0400 Subject: [PATCH] New Would You Rather API --- README.md | 4 ++-- commands/random-res/would-you-rather.js | 20 +++++++++----------- package.json | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c89e57eb..22f82792 100644 --- a/README.md +++ b/README.md @@ -1048,6 +1048,8 @@ here. * undertale ([Apple Kid Font](https://earthboundcentral.com/2009/11/ultimate-earthbound-font-pack/)) - [ebearskittychan](https://twitter.com/ebearskittychan) * temmie (English-to-Temmie Dictionary Data) +- [either](http://either.io) + * would-you-rather (API) - [Enkidulga](https://www.dafont.com/profile.php?user=736583) * ace-attorney ([Ace Attorney Font](https://www.dafont.com/ace-attorney.font)) - [Esther Verkest](https://www.facebook.com/Esther-Verkest-49667161749/) @@ -1539,8 +1541,6 @@ here. * final-grade (Concept, Code) - [Rotten Tomatoes](https://www.rottentomatoes.com/) * rotten-tomatoes (API) -- [rrrather](https://www.rrrather.com/) - * would-you-rather ([API](https://www.rrrather.com/botapi)) - [Ryan Gutierrez](https://twitter.com/gootecks) * pogchamp (Image) - [Safebooru](https://safebooru.org/) diff --git a/commands/random-res/would-you-rather.js b/commands/random-res/would-you-rather.js index 9f4a99c2..0d5390db 100644 --- a/commands/random-res/would-you-rather.js +++ b/commands/random-res/would-you-rather.js @@ -12,26 +12,24 @@ module.exports = class WouldYouRatherCommand extends Command { description: 'Responds with a random "Would you rather ...?" question.', credit: [ { - name: 'rrrather', - url: 'https://www.rrrather.com/', - reason: 'API', - reasonURL: 'https://www.rrrather.com/botapi' + name: 'either', + url: 'http://either.io', + reason: 'API' } ] }); } async run(msg) { - const data = await this.fetchScenario(msg.channel.nsfw || false); + const data = await this.fetchScenario(); return msg.say(stripIndents` - ${data.title} - **${data.choicea}** or **${data.choiceb}** + ${data.prefix ? `${data.prefix}, would you rather...` : 'Would you rather...'} + **${data.option_1}** or **${data.option_2}** `); } - async fetchScenario(nsfw) { - const { body } = await request.get('https://www.rrrather.com/botapi'); - if (body.nsfw && !nsfw) return this.fetchScenario(nsfw); - return body; + async fetchScenario() { + const { text } = await request.get('http://either.io/'); + return JSON.parse(text.match(/window.initial_question = (\{.+\})/)[1]).question; } }; diff --git a/package.json b/package.json index 3521dd3a..c936881a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.23.1", + "version": "119.23.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {