From e15e63120288425e8558230399a71a81131ff5bc Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 24 May 2020 14:32:36 -0400 Subject: [PATCH] Change Yoda API --- README.md | 4 ++-- commands/edit-text/yoda.js | 26 ++++++++++---------------- package.json | 3 +-- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 07f9d252..4ff5c772 100644 --- a/README.md +++ b/README.md @@ -1259,6 +1259,8 @@ here. * hollywood-star ([Image](http://www.redkid.net/generator/star/)) - [Rest Countries](https://restcountries.eu/) * country (API) +- [richchurcher](https://github.com/richchurcher) + * yoda ([API](https://github.com/richchurcher/yoda-api)) - [Right Stuf Anime](https://www.rightstufanime.com/) * right-stuf (API) - [Riot Games](https://www.riotgames.com/en) @@ -1337,8 +1339,6 @@ here. * newspaper (API) - [The Onion](https://www.theonion.com/) * the-onion ([RSS Feed](https://www.theonion.com/rss)) -- [The Yoda-Speak Generator](https://www.yodaspeak.co.uk/) - * yoda (API) - [This Waifu Does Not Exist](https://www.thiswaifudoesnotexist.net/) * waifu (API) - [Tim's Printables](https://www.timvandevall.com/) diff --git a/commands/edit-text/yoda.js b/commands/edit-text/yoda.js index 6e54d22c..563d8aca 100644 --- a/commands/edit-text/yoda.js +++ b/commands/edit-text/yoda.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const soap = require('soap'); +const request = require('node-superfetch'); module.exports = class YodaCommand extends Command { constructor(client) { @@ -11,9 +11,10 @@ module.exports = class YodaCommand extends Command { description: 'Converts text to Yoda speak.', credit: [ { - name: 'The Yoda-Speak Generator', - url: 'https://www.yodaspeak.co.uk/', - reason: 'API' + name: 'richchurcher', + url: 'https://github.com/richchurcher', + reason: 'API', + reasonURL: 'https://github.com/richchurcher/yoda-api' } ], args: [ @@ -25,24 +26,17 @@ module.exports = class YodaCommand extends Command { } ] }); - - this.soapClient = null; } async run(msg, { sentence }) { try { - if (!this.soapClient) await this.setUpClient(); - const response = await this.soapClient.yodaTalkAsync({ inputText: sentence }); - const text = response[0].return; - if (!text) return msg.reply('Empty, this message is. Try again later, you must.'); - return msg.say(text); + const { body } = await request + .get('https://yoda-api.appspot.com/api/v1/yodish') + .query({ text: sentence }); + if (!body.yodish) return msg.reply('Empty, this message is. Try again later, you must.'); + return msg.say(body.yodish); } catch (err) { return msg.reply(`Being a jerk again, Yoda is: \`${err.message}\`. Try again later, you must.`); } } - - async setUpClient() { - this.soapClient = await soap.createClientAsync('http://www.yodaspeak.co.uk/webservice/yodatalk.php?wsdl'); - return this.soapClient; - } }; diff --git a/package.json b/package.json index 8b8622cd..9f12aa91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.28.1", + "version": "114.28.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -53,7 +53,6 @@ "pokersolver": "^2.1.3", "random-js": "^2.1.0", "rss-parser": "^3.8.0", - "soap": "^0.31.0", "winston": "^3.2.1" }, "optionalDependencies": {