mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
args and more
This commit is contained in:
+22
-26
@@ -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!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user