mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 14:55:40 +02:00
Check if yodaspeak = ""
This commit is contained in:
+26
-22
@@ -20,28 +20,32 @@ class YodaCommand extends commando.Command {
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let yodaspeak = message.content.split(" ").slice(1).join("-");
|
||||
const options = {
|
||||
method: 'GET',
|
||||
uri: 'https://yoda.p.mashape.com/yoda',
|
||||
qs: {
|
||||
sentence: yodaspeak
|
||||
},
|
||||
headers: {
|
||||
'X-Mashape-Key': config.mashapekey,
|
||||
'Accept': "text/plain"
|
||||
},
|
||||
json: true
|
||||
}
|
||||
request(options).then(function (response) {
|
||||
if(response === undefined) {
|
||||
message.channel.sendMessage(':x: Error! Something went wrong! Keep it simple to avoid this error.');
|
||||
} else {
|
||||
let translated = response.split('-').join(" ");
|
||||
message.channel.sendMessage(translated).catch(error => message.channel.sendMessage(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.sendMessage(":x: Error!");
|
||||
});
|
||||
if(yodaspeak === "") {
|
||||
message.channel.sendMessage(':x: Error! Nothing to translate!');
|
||||
} else {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
uri: 'https://yoda.p.mashape.com/yoda',
|
||||
qs: {
|
||||
sentence: yodaspeak
|
||||
},
|
||||
headers: {
|
||||
'X-Mashape-Key': config.mashapekey,
|
||||
'Accept': "text/plain"
|
||||
},
|
||||
json: true
|
||||
}
|
||||
request(options).then(function (response) {
|
||||
if(response === undefined) {
|
||||
message.channel.sendMessage(':x: Error! Something went wrong! Keep it simple to avoid this error.');
|
||||
} else {
|
||||
let translated = response.split('-').join(" ");
|
||||
message.channel.sendMessage(translated).catch(error => message.channel.sendMessage(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.sendMessage(":x: Error! Unknown Error. Try again later!");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user