args and more

This commit is contained in:
Daniel Odendahl Jr
2017-03-25 04:16:27 +00:00
parent 8dd6ec1f9b
commit e2a4a92990
82 changed files with 1089 additions and 1021 deletions
+22 -26
View File
@@ -9,40 +9,36 @@ module.exports = class YodaCommand extends commando.Command {
group: 'textedit',
memberName: 'yoda',
description: 'Converts text to Yoda Speak. (;yoda This is Yoda.)',
examples: [';yoda This is Yoda.']
examples: [';yoda This is Yoda.'],
args: [{
key: 'text',
prompt: 'What text would you like to convert to Yoda speak?',
type: 'string'
}]
});
}
async run(message) {
async run(message, args) {
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) {
return message.channel.send(':x: Error! Nothing to translate!');
let turnToYoda = args.text;
try {
let response = await request
.get('https://yoda.p.mashape.com/yoda')
.set({
'X-Mashape-Key': config.mashapekey,
'Accept': 'text/plain'
})
.query({
sentence: turnToYoda
});
if (!response.text) return message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
return message.channel.send(response.text);
}
else {
try {
let response = await request
.get('https://yoda.p.mashape.com/yoda')
.set({
'X-Mashape-Key': config.mashapekey,
'Accept': 'text/plain'
})
.query({
sentence: turnToYoda
});
if (!response) {
return message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
}
else {
return message.channel.send(response.text);
}
}
catch (err) {
return message.channel.send(":x: Error! Something went wrong!");
}
catch (err) {
return message.channel.send(":x: Error! Something went wrong!");
}
}
};