Added Define Command

This commit is contained in:
dragonfire535
2017-03-05 21:47:11 -05:00
parent 5c5142b860
commit 35e65ea43a
2 changed files with 42 additions and 1 deletions
+1 -1
View File
@@ -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)")
"[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)")
.addField('My Server',
"[Click Here to Join!](https://discord.gg/fqQF8mc)")
.addField('Invite Link:',
+41
View File
@@ -0,0 +1,41 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const request = require('request-promise');
class DefineCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'define',
group: 'search',
memberName: 'define',
description: 'Defines the first word in your message. (;define Cat)',
examples: [';define Cat']
});
}
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;
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
}
console.log("[Command] " + message.content);
let [definethis] = message.content.toLowerCase().split(" ").slice(1);
const options = {
method: 'GET',
uri: 'https://owlbot.info/api/v1/dictionary/' + definethis + '?format=json',
json: true
}
request(options).then(function (response) {
const embed = new Discord.RichEmbed()
.setColor(0xF89C34)
.setTitle(definethis)
.setDescription(response[0].defenition)
message.channel.sendEmbed(embed).catch(console.error);
}).catch(function (err) {
message.channel.sendMessage(":x: Error! Word not Found!");
});
}
}
module.exports = DefineCommand;