diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index bf2b86d7..f1711ac4 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -54,7 +54,7 @@ class InfoCommand extends commando.Command { .addField('Library', "[discord.js](https://discord.js.org/#/)/[commando](https://github.com/Gawdl3y/discord.js-commando)") .addField('Modules', - "[cleverbot-node](https://github.com/fojas/cleverbot-node), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [JIMP](https://github.com/oliver-moran/jimp), [google-translate-api](https://github.com/matheuss/google-translate-api), [urban](https://github.com/mvrilo/urban), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather), [imdb-api](https://github.com/worr/node-imdb-api), [request-promise](https://github.com/request/request-promise), [mathjs](http://mathjs.org/), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [google](https://github.com/jprichardson/node-google), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format)") + "[cleverbot-node](https://github.com/fojas/cleverbot-node), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [JIMP](https://github.com/oliver-moran/jimp), [google-translate-api](https://github.com/matheuss/google-translate-api), [urban](https://github.com/mvrilo/urban), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather), [imdb-api](https://github.com/worr/node-imdb-api), [request-promise](https://github.com/request/request-promise), [mathjs](http://mathjs.org/), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [google](https://github.com/jprichardson/node-google), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [morse](https://github.com/ecto/morse)") .addField('Other Credit', "[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#), [YouTube Data API](https://developers.google.com/youtube/v3/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots API](https://bots.discord.pw/api), [Today in History API](http://history.muffinlabs.com/), [Heroku](https://www.heroku.com/)") .addField('My Server', diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js new file mode 100644 index 00000000..42c6d158 --- /dev/null +++ b/commands/textedit/morse.js @@ -0,0 +1,35 @@ +const commando = require('discord.js-commando'); +const morse = require('morse'); + +class MorseCommand extends commando.Command { + constructor(Client){ + super(Client, { + name: 'morse', + group: 'textedit', + memberName: 'morse', + description: 'Translates text to and from morse code. (;morse encode This is Morse Code.)', + examples: [';morse encode This is Morse Code.', ';morse decode .... . .-.. .-.. --- --..-- ....... .-- --- .-. .-.. -.. .-.-.-'] + }); + } + + async run(message, args) { + if(message.channel.type !== 'dm') { + if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return; + if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return; + } + console.log("[Command] " + message.content); + let [methodToUse] = message.content.toLowerCase().split(" ").slice(1); + let toMorse = message.content.split(" ").slice(2).join(" "); + if(toMorse === "") { + message.channel.send(":x: Error! Nothing to translate!"); + } else if(methodToUse === 'encode') { + message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?')); + } else if(methodToUse === 'decode') { + message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?')); + } else { + message.channel.send(":x: Error! Method not set/not correct! Use either encode or decode."); + } + } +} + +module.exports = MorseCommand; \ No newline at end of file diff --git a/commands/textedit/translate.js b/commands/textedit/translate.js index 40b9d6ea..878cbed2 100644 --- a/commands/textedit/translate.js +++ b/commands/textedit/translate.js @@ -10,7 +10,7 @@ class TranslateCommand extends commando.Command { group: 'textedit', memberName: 'translate', description: 'Translates text to a given language. (;translate ja Give me the money!) (;translate list to see avaliable language codes!)', - examples: [';translate ja Give me the the money!', ';translate'] + examples: [';translate ja Give me the the money!', ';translate list'] }); } diff --git a/package.json b/package.json index 03664ca5..429a1ab8 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "mathjs": "^3.10.0", "moment": "^2.17.1", "moment-duration-format": "^1.3.0", + "morse": "^0.1.0", "pirate-speak": "^1.0.1", "request-promise": "^4.1.1", "roman-numeral-converter-mmxvi": "^1.0.5",