mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Make it to where I no longer use Heroku for Yoda
This commit is contained in:
@@ -51,7 +51,6 @@ WEBSTER_KEY=
|
||||
WHATANIME_KEY=
|
||||
XIAO_GITHUB_REPO_NAME=
|
||||
XIAO_GITHUB_REPO_USERNAME=
|
||||
YODA_KEY=
|
||||
|
||||
# Imgur album IDs
|
||||
BLUSH_ALBUM_ID=
|
||||
|
||||
+13
-10
@@ -1,6 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { YODA_KEY } = process.env;
|
||||
const soap = require('soap');
|
||||
|
||||
module.exports = class YodaCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -25,20 +24,24 @@ module.exports = class YodaCommand extends Command {
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.soapClient = null;
|
||||
}
|
||||
|
||||
async run(msg, { sentence }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://yoda-speak-api.herokuapp.com/speak')
|
||||
.query({
|
||||
text: sentence,
|
||||
token: YODA_KEY
|
||||
});
|
||||
if (!body.response) return msg.reply('Empty, this message is. Try again later, you must.');
|
||||
return msg.say(body.response);
|
||||
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);
|
||||
} 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('https://www.yodaspeak.co.uk/webservice/yodatalk.php?wsdl');
|
||||
return this.soapClient;
|
||||
}
|
||||
};
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "109.0.1",
|
||||
"version": "109.0.2",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
@@ -46,6 +46,7 @@
|
||||
"moment-timezone": "^0.5.27",
|
||||
"node-superfetch": "^0.1.9",
|
||||
"random-js": "^2.1.0",
|
||||
"soap": "^0.30.0",
|
||||
"winston": "^3.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user