diff --git a/commands/random/cleverbot.js b/commands/random/cleverbot.js new file mode 100644 index 00000000..d0b1f9fc --- /dev/null +++ b/commands/random/cleverbot.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); +const request = require('superagent'); + +module.exports = class CleverbotCommand extends Command { + constructor(client) { + super(client, { + name: 'cleverbot', + aliases: [ + 'clevs', + 'chat' + ], + group: 'random', + memberName: 'cleverbot', + description: 'Talk to Cleverbot.', + args: [ + { + key: 'text', + prompt: 'What would you like to say to Cleverbot?', + type: 'string', + parse: text => encodeURIComponent(text) + } + ] + }); + } + + async run(msg, args) { + const { text } = args; + try { + const { body } = await request + .post('https://cleverbot.io/1.0/ask') + .send({ user: process.env.CLEVS_USER, key: process.env.CLEVS_KEY, text }); + if(body.status !== 'success') throw new Error(body.status); + return msg.reply(body.response); + } catch(err) { + return msg.say(`An Error Occurred: ${err}`); + } + } +}; diff --git a/commands/util/info.js b/commands/util/info.js index 9d974d3f..5e441844 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -84,7 +84,8 @@ module.exports = class InfoCommand extends Command { [SoundCloud](https://developers.soundcloud.com/), [random.cat](http://random.cat/), [random.dog](https://random.dog/), - [fixer.io](http://fixer.io/) + [fixer.io](http://fixer.io/), + [cleverbot.io](https://cleverbot.io/) ` ); return msg.embed(embed); diff --git a/html/carbondesc.html b/html/carbondesc.html index 76605f05..bb7d8e51 100644 --- a/html/carbondesc.html +++ b/html/carbondesc.html @@ -52,6 +52,7 @@