From e2d2ed9b60a01bfda059d3224aabf2af1409f9d2 Mon Sep 17 00:00:00 2001 From: dragonfire535 Date: Sun, 5 Mar 2017 22:45:09 -0500 Subject: [PATCH] Switch to Wordnik (Temp API Key) --- commands/botinfo/info.js | 2 +- commands/search/define.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index 2e0aa18f..47bf5d05 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -61,7 +61,7 @@ class InfoCommand extends commando.Command { .addField('Packages', "[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), [wikifakt](https://github.com/coffee-cup/wikifakt) (1.0.3), [osu](https://github.com/IOExceptionOsu/node-osu) (1.0.1), [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)") .addField('Other Credit', - "[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [OwlBot Defenition API](https://owlbot.info/api/v1/dictionary/owl)") + "[Cleverbot API](https://www.cleverbot.com/api/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html)") .addField('My Server', "[Click Here to Join!](https://discord.gg/fqQF8mc)") .addField('Invite Link:', diff --git a/commands/search/define.js b/commands/search/define.js index c03e506b..842f07c1 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -1,6 +1,7 @@ const commando = require('discord.js-commando'); const Discord = require('discord.js'); const request = require('request-promise'); +const config = require('../../config.json'); class DefineCommand extends commando.Command { constructor(Client){ @@ -8,7 +9,7 @@ class DefineCommand extends commando.Command { name: 'define', group: 'search', memberName: 'define', - description: 'Defines the first word in your message. (;define Cat)', + description: 'Defines a word. (;define Cat)', examples: [';define Cat'] }); } @@ -20,17 +21,17 @@ class DefineCommand extends commando.Command { if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return; } console.log("[Command] " + message.content); - let [definethis] = message.content.toLowerCase().split(" ").slice(1); + let definethis = message.content.toLowerCase().split(" ").slice(1).join("%20"); const options = { method: 'GET', - uri: 'https://owlbot.info/api/v1/dictionary/' + definethis + '?format=json', + uri: 'http://api.wordnik.com:80/v4/word.json/' + definethis + '/definitions?limit=1&includeRelated=false&useCanonical=false&includeTags=false&api_key=' + config.wordnikkey, json: true } request(options).then(function (response) { const embed = new Discord.RichEmbed() .setColor(0x0000FF) - .setTitle(definethis) - .setDescription(response[0].defenition); + .setTitle(response[0].word) + .setDescription(response[0].text); message.channel.sendEmbed(embed).catch(console.error); }).catch(function (err) { message.channel.sendMessage(":x: Error! Word not Found!");