mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Change Yoda API
This commit is contained in:
+10
-16
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user