Formatting

This commit is contained in:
Daniel Odendahl Jr
2017-03-23 01:35:22 +00:00
parent 72718c7c62
commit 40a4af36c4
109 changed files with 2660 additions and 2505 deletions
+25 -18
View File
@@ -3,7 +3,7 @@ const request = require('superagent');
const config = require('../../config.json');
module.exports = class YodaCommand extends commando.Command {
constructor(Client){
constructor(Client) {
super(Client, {
name: 'yoda',
group: 'textedit',
@@ -14,27 +14,34 @@ module.exports = class YodaCommand extends commando.Command {
}
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let turnToYoda = message.content.split(" ").slice(1).join(" ");
if(turnToYoda === "") {
if (turnToYoda === "") {
message.channel.send(':x: Error! Nothing to translate!');
} else {
}
else {
request
.get('https://yoda.p.mashape.com/yoda')
.set({ 'X-Mashape-Key': config.mashapekey, 'Accept': 'text/plain' })
.query({ sentence: turnToYoda })
.then(function (response) {
if(response === undefined) {
message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
} else {
message.channel.send(response.text).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
}
}).catch(function (err) {
message.channel.send(":x: Error! Unknown Error. Try again later!");
});
.get('https://yoda.p.mashape.com/yoda')
.set({
'X-Mashape-Key': config.mashapekey,
'Accept': 'text/plain'
})
.query({
sentence: turnToYoda
})
.then(function(response) {
if (response === undefined) {
message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
}
else {
message.channel.send(response.text).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
}
}).catch(function(err) {
message.channel.send(":x: Error! Unknown Error. Try again later!");
});
}
}
};
};