mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
Switch to Wordnik (Temp API Key)
This commit is contained in:
@@ -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!");
|
||||
|
||||
Reference in New Issue
Block a user