Added Bot Search

This commit is contained in:
dragonfire535
2017-03-12 23:24:09 -04:00
parent 9ba91a1c3f
commit 383b58c894
2 changed files with 58 additions and 1 deletions
+1 -1
View File
@@ -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), [string-to-binary](https://www.npmjs.com/package/string-to-binary) (0.1.2)")
.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/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [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), [Discord Bots API](https://bots.discord.pw/api), [Heroku](https://www.heroku.com/)")
.addField('My Server',
"[Click Here to Join!](https://discord.gg/fqQF8mc)")
.addField('Invite Link:',
+57
View File
@@ -0,0 +1,57 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const request = require('request-promise');
const config = require('../../config.json');
class BotSearchCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'botinfo',
group: 'search',
memberName: 'botinfo',
description: 'Searches Discord Bots for info on a bot. (;botinfo @Bot)',
examples: [';botinfo @Bot']
});
}
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);
if(message.mentions.users.size === 1) {
let botToFind = message.mentions.users.first().id;
const options = {
method: 'GET',
uri: 'https://bots.discord.pw/api/bots/' + botToFind,
headers: {
'Authorization': config.botskey
},
json: true
}
request(options).then(function (response) {
const embed = new Discord.RichEmbed()
.setColor(0x9797FF)
.setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg')
.setTitle(response.name)
.setURL('https://bots.discord.pw/')
.setDescription(response.description)
.addField('**Library:**',
response.library, true)
.addField('**Prefix:**',
response.prefix, true)
.addField('**Invite:**',
'[Here](' + response.invite_url + ')', true);
message.channel.sendEmbed(embed).catch(console.error);
}).catch(function (err) {
message.channel.sendMessage(":x: Error! Bot not Found!");
});
} else {
message.channel.sendMessage(':x: Either too many or no bots, only mention one bot!');
}
}
}
module.exports = BotSearchCommand;