diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index 0e9cc714..62d0b3eb 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -60,7 +60,7 @@ class InfoCommand extends commando.Command { .addField('Modules', "[Commando](https://github.com/Gawdl3y/discord.js-commando) (0.9.0), [cleverbot-node](https://github.com/fojas/cleverbot-node) (0.3.5), [pirate-speak](https://github.com/mikewesthad/pirate-speak) (1.0.1), [JIMP](https://github.com/oliver-moran/jimp) (0.2.27), [google-translate-api](https://github.com/matheuss/google-translate-api) (2.2.2), [urban](https://github.com/mvrilo/urban) (0.3.1), [zalgoize](https://github.com/clux/zalgolize) (1.2.4), [hepburn](https://github.com/lovell/hepburn) (1.0.0), [yahoo-weather](https://github.com/mamal72/node-yahoo-weather) (2.2.2), [imdb-api](https://github.com/worr/node-imdb-api) (2.2.1), [request-promise](https://github.com/request/request-promise) (4.1.1), [mathjs](http://mathjs.org/) (3.10.0)") .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/), [Heroku](https://www.heroku.com/)") + "[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), [Heroku](https://www.heroku.com/)") .addField('My Server', "[Click Here to Join!](https://discord.gg/fqQF8mc)") .addField('Invite Link:', diff --git a/commands/textedit/yoda.js b/commands/textedit/yoda.js new file mode 100644 index 00000000..3e760957 --- /dev/null +++ b/commands/textedit/yoda.js @@ -0,0 +1,48 @@ +const commando = require('discord.js-commando'); +const request = require('request-promise'); +const config = require('../../config.json'); + +class YodaCommand extends commando.Command { + constructor(Client){ + super(Client, { + name: 'yoda', + group: 'textedit', + memberName: 'yoda', + description: 'Converts text to Yoda Speak. (;yoda This is Yoda.)', + examples: [';yoda This is Yoda.'] + }); + } + + 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 yodaspeak = message.content.split(" ").slice(1).join("-"); + const options = { + method: 'GET', + uri: 'https://yoda.p.mashape.com/yoda', + qs: { + sentence: yodaspeak + }, + headers: { + 'X-Mashape-Key': config.mashapekey, + 'Accept': "text/plain" + }, + json: true + } + request(options).then(function (response) { + if(response === undefined) { + message.channel.sendMessage(':x: Error! Something went wrong! Keep it simple to avoid this error.'); + } else { + let translated = response.split('-').join(" "); + message.channel.sendMessage(translated); + } + }).catch(function (err) { + message.channel.sendMessage(":x: Error!"); + }); + } +} + +module.exports = YodaCommand; \ No newline at end of file