Fix All the Crap

This commit is contained in:
Daniel Odendahl Jr
2017-03-25 04:52:59 +00:00
parent ebfbf31787
commit cb4abd7ac4
12 changed files with 42 additions and 59 deletions
+2 -4
View File
@@ -15,10 +15,7 @@ module.exports = class MorseCommand extends commando.Command {
args: [{
key: 'method',
prompt: 'Would you like to encode or decode the text?',
type: 'string',
validate: (str) => {
str.toLowerCase() === 'encode' || str.toLowerCase() === 'decode';
}
type: 'string'
}, {
key: 'text',
prompt: 'What text would you like to convert to morse?',
@@ -33,6 +30,7 @@ module.exports = class MorseCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let methodToUse = args.method;
if (methodToUse.toLowerCase() !== 'encode' || methodToUse.toLowerCase() !== 'decode') return message.channel.send(':x: Error! Please set either encode or decode!');
let toMorse = args.text;
if (methodToUse === 'encode') return message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
if (methodToUse === 'decode') return message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));