mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Formatting
This commit is contained in:
+28
-25
@@ -4,7 +4,7 @@ const request = require('superagent');
|
||||
const config = require('../../config.json');
|
||||
|
||||
module.exports = class BotSearchCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'botinfo',
|
||||
aliases: [
|
||||
@@ -19,34 +19,37 @@ module.exports = class BotSearchCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
if(message.mentions.users.size === 1) {
|
||||
if (message.mentions.users.size === 1) {
|
||||
let botToFind = message.mentions.users.first().id;
|
||||
request
|
||||
.get('https://bots.discord.pw/api/bots/' + botToFind)
|
||||
.set({ 'Authorization': config.botskey })
|
||||
.then(function (response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg')
|
||||
.setTitle(response.body.name)
|
||||
.setURL('https://bots.discord.pw/')
|
||||
.setDescription(response.body.description)
|
||||
.addField('**Library:**',
|
||||
response.body.library, true)
|
||||
.addField('**Prefix:**',
|
||||
response.body.prefix, true)
|
||||
.addField('**Invite:**',
|
||||
'[Here](' + response.body.invite_url + ')', true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! Bot not Found!");
|
||||
});
|
||||
} else {
|
||||
.get('https://bots.discord.pw/api/bots/' + botToFind)
|
||||
.set({
|
||||
'Authorization': config.botskey
|
||||
})
|
||||
.then(function(response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg')
|
||||
.setTitle(response.body.name)
|
||||
.setURL('https://bots.discord.pw/')
|
||||
.setDescription(response.body.description)
|
||||
.addField('**Library:**',
|
||||
response.body.library, true)
|
||||
.addField('**Prefix:**',
|
||||
response.body.prefix, true)
|
||||
.addField('**Invite:**',
|
||||
'[Here](' + response.body.invite_url + ')', true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! Bot not Found!");
|
||||
});
|
||||
}
|
||||
else {
|
||||
message.channel.send(':x: Please mention one bot!');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+21
-15
@@ -4,7 +4,7 @@ const request = require('superagent');
|
||||
const config = require('../../config.json');
|
||||
|
||||
module.exports = class DefineCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'define',
|
||||
aliases: [
|
||||
@@ -21,22 +21,28 @@ module.exports = class DefineCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let defineThis = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||
request
|
||||
.get('http://api.wordnik.com:80/v4/word.json/' + defineThis + '/definitions')
|
||||
.query({ limit: 1, includeRelated: false, useCanonical: false, includeTags: false, api_key: config.wordnikkey })
|
||||
.then(function (response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(response.body[0].word)
|
||||
.setDescription(response.body[0].text);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! Word not Found!");
|
||||
});
|
||||
.get('http://api.wordnik.com:80/v4/word.json/' + defineThis + '/definitions')
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
useCanonical: false,
|
||||
includeTags: false,
|
||||
api_key: config.wordnikkey
|
||||
})
|
||||
.then(function(response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(response.body[0].word)
|
||||
.setDescription(response.body[0].text);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! Word not Found!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const commando = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
|
||||
module.exports = class DiscrimCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'discrim',
|
||||
aliases: [
|
||||
@@ -17,19 +17,20 @@ module.exports = class DiscrimCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let userToSearch = message.content.split(" ").slice(1).join(" ");
|
||||
if(userToSearch.match(/^[0-9]+$/) && userToSearch.split("").length === 4) {
|
||||
if (userToSearch.match(/^[0-9]+$/) && userToSearch.split("").length === 4) {
|
||||
let users = this.client.users.filter(u => u.discriminator === userToSearch).map(u => u.username).sort();
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle(users.length + ' Users with the discriminator: ' + userToSearch)
|
||||
.setDescription(users.join(', '));
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
} else {
|
||||
.setTitle(users.length + ' Users with the discriminator: ' + userToSearch)
|
||||
.setDescription(users.join(', '));
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
else {
|
||||
message.channel.send(':x: Error! This discriminator is invalid!');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+22
-22
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const weather = require('yahoo-weather');
|
||||
|
||||
module.exports = class ForecastCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'forecast',
|
||||
aliases: [
|
||||
@@ -17,34 +17,34 @@ module.exports = class ForecastCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
||||
weather(locationToSearch, 'f').then(info => {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||
.setURL(info.link)
|
||||
.setTimestamp()
|
||||
.addField('**' + info.item.forecast[0].day + " - " + info.item.forecast[0].date + ':**',
|
||||
'**High:** ' + info.item.forecast[0].high + ', **Low:** ' + info.item.forecast[0].low + ', **Condition:** ' + info.item.forecast[0].text)
|
||||
.addField('**' + info.item.forecast[1].day + " - " + info.item.forecast[1].date + ':**',
|
||||
'**High:** ' + info.item.forecast[1].high + ', **Low:** ' + info.item.forecast[1].low + ', **Condition:** ' + info.item.forecast[1].text)
|
||||
.addField('**' + info.item.forecast[2].day + " - " + info.item.forecast[2].date + ':**',
|
||||
'**High:** ' + info.item.forecast[2].high + ', **Low:** ' + info.item.forecast[2].low + ', **Condition:** ' + info.item.forecast[2].text)
|
||||
.addField('**' + info.item.forecast[3].day + " - " + info.item.forecast[3].date + ':**',
|
||||
'**High:** ' + info.item.forecast[3].high + ', **Low:** ' + info.item.forecast[3].low + ', **Condition:** ' + info.item.forecast[3].text)
|
||||
.addField('**' + info.item.forecast[4].day + " - " + info.item.forecast[4].date + ':**',
|
||||
'**High:** ' + info.item.forecast[4].high + ', **Low:** ' + info.item.forecast[4].low + ', **Condition:** ' + info.item.forecast[4].text)
|
||||
.addField('**' + info.item.forecast[5].day + " - " + info.item.forecast[5].date + ':**',
|
||||
'**High:** ' + info.item.forecast[5].high + ', **Low:** ' + info.item.forecast[5].low + ', **Condition:** ' + info.item.forecast[5].text)
|
||||
.addField('**' + info.item.forecast[6].day + " - " + info.item.forecast[6].date + ':**',
|
||||
'**High:** ' + info.item.forecast[6].high + ', **Low:** ' + info.item.forecast[6].low + ', **Condition:** ' + info.item.forecast[6].text);
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||
.setURL(info.link)
|
||||
.setTimestamp()
|
||||
.addField('**' + info.item.forecast[0].day + " - " + info.item.forecast[0].date + ':**',
|
||||
'**High:** ' + info.item.forecast[0].high + ', **Low:** ' + info.item.forecast[0].low + ', **Condition:** ' + info.item.forecast[0].text)
|
||||
.addField('**' + info.item.forecast[1].day + " - " + info.item.forecast[1].date + ':**',
|
||||
'**High:** ' + info.item.forecast[1].high + ', **Low:** ' + info.item.forecast[1].low + ', **Condition:** ' + info.item.forecast[1].text)
|
||||
.addField('**' + info.item.forecast[2].day + " - " + info.item.forecast[2].date + ':**',
|
||||
'**High:** ' + info.item.forecast[2].high + ', **Low:** ' + info.item.forecast[2].low + ', **Condition:** ' + info.item.forecast[2].text)
|
||||
.addField('**' + info.item.forecast[3].day + " - " + info.item.forecast[3].date + ':**',
|
||||
'**High:** ' + info.item.forecast[3].high + ', **Low:** ' + info.item.forecast[3].low + ', **Condition:** ' + info.item.forecast[3].text)
|
||||
.addField('**' + info.item.forecast[4].day + " - " + info.item.forecast[4].date + ':**',
|
||||
'**High:** ' + info.item.forecast[4].high + ', **Low:** ' + info.item.forecast[4].low + ', **Condition:** ' + info.item.forecast[4].text)
|
||||
.addField('**' + info.item.forecast[5].day + " - " + info.item.forecast[5].date + ':**',
|
||||
'**High:** ' + info.item.forecast[5].high + ', **Low:** ' + info.item.forecast[5].low + ', **Condition:** ' + info.item.forecast[5].text)
|
||||
.addField('**' + info.item.forecast[6].day + " - " + info.item.forecast[6].date + ':**',
|
||||
'**High:** ' + info.item.forecast[6].high + ', **Low:** ' + info.item.forecast[6].low + ', **Condition:** ' + info.item.forecast[6].text);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(err => {
|
||||
message.channel.send(":x: Error! Make sure you typed the location correctly!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+17
-16
@@ -4,7 +4,7 @@ const cheerio = require('cheerio');
|
||||
const querystring = require('querystring');
|
||||
|
||||
module.exports = class DefineCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'google',
|
||||
aliases: [
|
||||
@@ -18,23 +18,24 @@ module.exports = class DefineCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||
message.channel.send('Searching...');
|
||||
const SEARCH_URL = `https://www.google.com/search?q=${thingToSearch}`;
|
||||
request
|
||||
.get(SEARCH_URL)
|
||||
.then(function (response) {
|
||||
const $ = cheerio.load(response.text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) return Promise.reject(new Error('NO RESULTS'));
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
message.channel.send(href.q);
|
||||
}).catch(function (err) {
|
||||
message.channel.send(':x: Error! No Results Found!');
|
||||
message.channel.send('Searching...').then(msg => {
|
||||
const SEARCH_URL = `https://www.google.com/search?q=${thingToSearch}`;
|
||||
request
|
||||
.get(SEARCH_URL)
|
||||
.then(function(response) {
|
||||
const $ = cheerio.load(response.text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) return Promise.reject(new Error('NO RESULTS'));
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
msg.edit(href.q);
|
||||
}).catch(function(err) {
|
||||
message.channel.send(':x: Error! No Results Found!');
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+30
-27
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const imdb = require('imdb-api');
|
||||
|
||||
module.exports = class IMDBCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'imdb',
|
||||
aliases: [
|
||||
@@ -19,39 +19,42 @@ module.exports = class IMDBCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let queryMovie = message.content.split(" ").slice(1).join(" ");
|
||||
let movie;
|
||||
imdb.getReq({ name: queryMovie }, (err, response) => {
|
||||
imdb.getReq({
|
||||
name: queryMovie
|
||||
}, (err, response) => {
|
||||
movie = response;
|
||||
if(movie === undefined) {
|
||||
if (movie === undefined) {
|
||||
message.channel.send(":x: Error! Movie not found!");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xDBA628)
|
||||
.setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png')
|
||||
.setURL(movie.imdburl)
|
||||
.setTitle(movie.title + ' (' + movie.rating + ' Score)')
|
||||
.setDescription(movie.plot.substr(0, 1500) + " [Read the Rest Here!](" + movie.imdburl + ")")
|
||||
.addField('**Genres:**',
|
||||
movie.genres)
|
||||
.addField('**Year:**',
|
||||
movie.year, true)
|
||||
.addField('**Rated:**',
|
||||
movie.rated, true)
|
||||
.addField('**Runtime:**',
|
||||
movie.runtime, true)
|
||||
.addField('**Directors:**',
|
||||
movie.director)
|
||||
.addField('**Writers:**',
|
||||
movie.writer)
|
||||
.addField('**Actors:**',
|
||||
movie.actors);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
.setColor(0xDBA628)
|
||||
.setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png')
|
||||
.setURL(movie.imdburl)
|
||||
.setTitle(movie.title + ' (' + movie.rating + ' Score)')
|
||||
.setDescription(movie.plot.substr(0, 1500) + " [Read the Rest Here!](" + movie.imdburl + ")")
|
||||
.addField('**Genres:**',
|
||||
movie.genres)
|
||||
.addField('**Year:**',
|
||||
movie.year, true)
|
||||
.addField('**Rated:**',
|
||||
movie.rated, true)
|
||||
.addField('**Runtime:**',
|
||||
movie.runtime, true)
|
||||
.addField('**Directors:**',
|
||||
movie.director)
|
||||
.addField('**Writers:**',
|
||||
movie.writer)
|
||||
.addField('**Actors:**',
|
||||
movie.actors);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const commando = require('discord.js-commando');
|
||||
|
||||
module.exports = class NeopetCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'neopet',
|
||||
group: 'search',
|
||||
@@ -12,15 +12,16 @@ module.exports = class NeopetCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let petID = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||
if(petID === "getid") {
|
||||
message.channel.send("To get your pet's ID, simply go to http://www.sunnyneo.com/petimagefinder.php and enter your pet's name. It's image should show up. Then, find the link below the pet's image, and copy it to your message!").then(message.channel.sendFile('./images/PetID.png').then(message.channel.send("It's recommended you keep this ID with you so you can easily share your pet's picture without having to repeat these steps.")));
|
||||
} else {
|
||||
message.channel.send("Result for: " + petID).then(message.channel.sendFile('http://pets.neopets.com/cp/' + petID + '/1/5.png').catch(error => message.channel.send(":x: Error! Pet ID Not Found! Use `;neopet getID` for help on getting your pet ID.")));
|
||||
if (petID === "getid") {
|
||||
message.channel.send("To get your pet's ID, simply go to http://www.sunnyneo.com/petimagefinder.php and enter your pet's name. It's image should show up. Then, find the link below the pet's image, and copy it to your message!").then(message.channel.sendFile('./images/PetID.png').then(message.channel.send("It's recommended you keep this ID with you so you can easily share your pet's picture without having to repeat these steps.")));
|
||||
}
|
||||
else {
|
||||
message.channel.send("Result for: " + petID).then(message.channel.sendFile('http://pets.neopets.com/cp/' + petID + '/1/5.png').catch(error => message.channel.send(":x: Error! Pet ID Not Found! Use `;neopet getID` for help on getting your pet ID.")));
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+48
-43
@@ -4,7 +4,7 @@ const config = require('../../config.json');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class OsuCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'osu',
|
||||
aliases: [
|
||||
@@ -20,50 +20,55 @@ module.exports = class OsuCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let usernameToSearch = message.content.split(" ").slice(1).join(" ");
|
||||
request
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({ k: config.osukey, u: usernameToSearch, type: 'string' })
|
||||
.then(function (response) {
|
||||
if(response.body[0] === undefined) {
|
||||
message.channel.send(":x: Error! User not found!");
|
||||
} else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209')
|
||||
.setURL('https://osu.ppy.sh/')
|
||||
.addField('**Username:**',
|
||||
response.body[0].username, true)
|
||||
.addField('**ID:**',
|
||||
response.body[0].user_id, true)
|
||||
.addField('**Level:**',
|
||||
response.body[0].level, true)
|
||||
.addField('**Accuracy**',
|
||||
response.body[0].accuracy, true)
|
||||
.addField('**Rank:**',
|
||||
response.body[0].pp_rank, true)
|
||||
.addField('**Play Count:**',
|
||||
response.body[0].playcount, true)
|
||||
.addField('**Country:**',
|
||||
response.body[0].country, true)
|
||||
.addField('**Ranked Score:**',
|
||||
response.body[0].ranked_score, true)
|
||||
.addField('**Total Score:**',
|
||||
response.body[0].total_score, true)
|
||||
.addField('**SS:**',
|
||||
response.body[0].count_rank_ss, true)
|
||||
.addField('**S:**',
|
||||
response.body[0].count_rank_s, true)
|
||||
.addField('**A:**',
|
||||
response.body[0].count_rank_a, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! User not Found!");
|
||||
});
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({
|
||||
k: config.osukey,
|
||||
u: usernameToSearch,
|
||||
type: 'string'
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.body[0] === undefined) {
|
||||
message.channel.send(":x: Error! User not found!");
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209')
|
||||
.setURL('https://osu.ppy.sh/')
|
||||
.addField('**Username:**',
|
||||
response.body[0].username, true)
|
||||
.addField('**ID:**',
|
||||
response.body[0].user_id, true)
|
||||
.addField('**Level:**',
|
||||
response.body[0].level, true)
|
||||
.addField('**Accuracy**',
|
||||
response.body[0].accuracy, true)
|
||||
.addField('**Rank:**',
|
||||
response.body[0].pp_rank, true)
|
||||
.addField('**Play Count:**',
|
||||
response.body[0].playcount, true)
|
||||
.addField('**Country:**',
|
||||
response.body[0].country, true)
|
||||
.addField('**Ranked Score:**',
|
||||
response.body[0].ranked_score, true)
|
||||
.addField('**Total Score:**',
|
||||
response.body[0].total_score, true)
|
||||
.addField('**SS:**',
|
||||
response.body[0].count_rank_ss, true)
|
||||
.addField('**S:**',
|
||||
response.body[0].count_rank_s, true)
|
||||
.addField('**A:**',
|
||||
response.body[0].count_rank_a, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! User not Found!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+1261
-1261
File diff suppressed because it is too large
Load Diff
+16
-15
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const pokedex = require('./pkdex.json');
|
||||
|
||||
module.exports = class PokedexCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'pokedex',
|
||||
aliases: [
|
||||
@@ -17,26 +17,27 @@ module.exports = class PokedexCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let pokemon = message.content.toLowerCase().split(" ").slice(1).join(" ");
|
||||
if (pokedex.name[pokemon]) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle('Information')
|
||||
.setAuthor('#' + pokedex.index[pokemon] + " " + pokedex.name[pokemon], 'http://www.serebii.net/pokedex-sm/icon/' + pokedex.index[pokemon] + '.png')
|
||||
.setColor(0xFF0000)
|
||||
.setDescription(pokedex.species[pokemon])
|
||||
.setFooter("Pokédex", "http://cdn.bulbagarden.net/upload/thumb/3/36/479Rotom-Pokédex.png/250px-479Rotom-Pokédex.png")
|
||||
.setThumbnail('http://www.serebii.net/sunmoon/pokemon/' + pokedex.index[pokemon] + '.png')
|
||||
.addField('Entry',
|
||||
pokedex.entry[pokemon])
|
||||
.addField('Type',
|
||||
pokedex.type[pokemon]);
|
||||
.setTitle('Information')
|
||||
.setAuthor('#' + pokedex.index[pokemon] + " " + pokedex.name[pokemon], 'http://www.serebii.net/pokedex-sm/icon/' + pokedex.index[pokemon] + '.png')
|
||||
.setColor(0xFF0000)
|
||||
.setDescription(pokedex.species[pokemon])
|
||||
.setFooter("Pokédex", "http://cdn.bulbagarden.net/upload/thumb/3/36/479Rotom-Pokédex.png/250px-479Rotom-Pokédex.png")
|
||||
.setThumbnail('http://www.serebii.net/sunmoon/pokemon/' + pokedex.index[pokemon] + '.png')
|
||||
.addField('Entry',
|
||||
pokedex.entry[pokemon])
|
||||
.addField('Type',
|
||||
pokedex.type[pokemon]);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
message.channel.send(":x: This Pokémon either doesn't exist, or isn't implemented yet.");
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+24
-21
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const urban = require('urban');
|
||||
|
||||
module.exports = class UrbanDictionary extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'urban',
|
||||
aliases: [
|
||||
@@ -17,37 +17,40 @@ module.exports = class UrbanDictionary extends commando.Command {
|
||||
examples: [';urban Cat']
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let wordToDefine = message.content.split(" ").slice(1).join(" ");
|
||||
urban(wordToDefine).first(function(response) {
|
||||
if(response === undefined) {
|
||||
if (response === undefined) {
|
||||
message.channel.send(":x: Error! Word not found!");
|
||||
} else if(response.definition === '') {
|
||||
}
|
||||
else if (response.definition === '') {
|
||||
message.channel.send(":x: Error! Word has no definition!");
|
||||
} else if(response.example !== '') {
|
||||
}
|
||||
else if (response.example !== '') {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png')
|
||||
.setURL(response.permalink)
|
||||
.setTitle(response.word)
|
||||
.setDescription(response.definition.substr(0, 1900) + ' [Read the Rest Here!](' + response.permalink + ')')
|
||||
.addField('**Example:**',
|
||||
response.example.substr(0, 1900));
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png')
|
||||
.setURL(response.permalink)
|
||||
.setTitle(response.word)
|
||||
.setDescription(response.definition.substr(0, 1900) + ' [Read the Rest Here!](' + response.permalink + ')')
|
||||
.addField('**Example:**',
|
||||
response.example.substr(0, 1900));
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png')
|
||||
.setURL(response.permalink)
|
||||
.setTitle(response.word)
|
||||
.setDescription(response.definition.substr(0, 1900) + ' [Read the Rest Here!](' + response.permalink + ')');
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png')
|
||||
.setURL(response.permalink)
|
||||
.setTitle(response.word)
|
||||
.setDescription(response.definition.substr(0, 1900) + ' [Read the Rest Here!](' + response.permalink + ')');
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+35
-30
@@ -4,7 +4,7 @@ const request = require('superagent');
|
||||
const config = require('../../config.json');
|
||||
|
||||
module.exports = class WattpadCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'wattpad',
|
||||
group: 'search',
|
||||
@@ -15,37 +15,42 @@ module.exports = class WattpadCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let queryBook = message.content.split(" ").slice(1).join(" ");
|
||||
request
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.set({ 'Authorization': 'Basic ' + config.wattpadkey })
|
||||
.query({ query: queryBook, limit: 1 })
|
||||
.then(function (response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'http://www.selfpubtoolbox.com/wp-content/uploads/2015/05/a6044fd3a88acd5043860484db972ca6.png')
|
||||
.setURL(response.body.stories[0].url)
|
||||
.setTitle(response.body.stories[0].title)
|
||||
.setDescription(response.body.stories[0].description.substr(0, 1500) + " [Read the Rest Here!](" + response.body.stories[0].url + ")")
|
||||
.addField('**Author:**',
|
||||
response.body.stories[0].user, true)
|
||||
.addField('**Parts:**',
|
||||
response.body.stories[0].numParts, true)
|
||||
.addField('**Created On:**',
|
||||
response.body.stories[0].createDate, true)
|
||||
.addField('**Votes:**',
|
||||
response.body.stories[0].voteCount, true)
|
||||
.addField('**Reads:**',
|
||||
response.body.stories[0].readCount, true)
|
||||
.addField('**Comments:**',
|
||||
response.body.stories[0].commentCount, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! Book not Found!");
|
||||
});
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.set({
|
||||
'Authorization': 'Basic ' + config.wattpadkey
|
||||
})
|
||||
.query({
|
||||
query: queryBook,
|
||||
limit: 1
|
||||
})
|
||||
.then(function(response) {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'http://www.selfpubtoolbox.com/wp-content/uploads/2015/05/a6044fd3a88acd5043860484db972ca6.png')
|
||||
.setURL(response.body.stories[0].url)
|
||||
.setTitle(response.body.stories[0].title)
|
||||
.setDescription(response.body.stories[0].description.substr(0, 1500) + " [Read the Rest Here!](" + response.body.stories[0].url + ")")
|
||||
.addField('**Author:**',
|
||||
response.body.stories[0].user, true)
|
||||
.addField('**Parts:**',
|
||||
response.body.stories[0].numParts, true)
|
||||
.addField('**Created On:**',
|
||||
response.body.stories[0].createDate, true)
|
||||
.addField('**Votes:**',
|
||||
response.body.stories[0].voteCount, true)
|
||||
.addField('**Reads:**',
|
||||
response.body.stories[0].readCount, true)
|
||||
.addField('**Comments:**',
|
||||
response.body.stories[0].commentCount, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! Book not Found!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+32
-32
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const weather = require('yahoo-weather');
|
||||
|
||||
module.exports = class WeatherCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'weather',
|
||||
group: 'search',
|
||||
@@ -14,44 +14,44 @@ module.exports = class WeatherCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
||||
weather(locationToSearch, 'f').then(info => {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||
.setURL(info.link)
|
||||
.setTimestamp()
|
||||
.addField('**City:**',
|
||||
info.location.city, true)
|
||||
.addField('**Country**',
|
||||
info.location.country, true)
|
||||
.addField('**Region:**',
|
||||
info.location.region, true)
|
||||
.addField('**Condition:**',
|
||||
info.item.condition.text, true)
|
||||
.addField('**Temperature:**',
|
||||
info.item.condition.temp + "°F", true)
|
||||
.addField('**Humidity:**',
|
||||
info.atmosphere.humidity, true)
|
||||
.addField('**Pressure:**',
|
||||
info.atmosphere.pressure, true)
|
||||
.addField('**Rising:**',
|
||||
info.atmosphere.rising, true)
|
||||
.addField('**Visibility:**',
|
||||
info.atmosphere.visibility, true)
|
||||
.addField('**Wind Chill:**',
|
||||
info.wind.chill, true)
|
||||
.addField('**Wind Direction:**',
|
||||
info.wind.direction, true)
|
||||
.addField('**Wind Speed:**',
|
||||
info.wind.speed, true);
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||
.setURL(info.link)
|
||||
.setTimestamp()
|
||||
.addField('**City:**',
|
||||
info.location.city, true)
|
||||
.addField('**Country**',
|
||||
info.location.country, true)
|
||||
.addField('**Region:**',
|
||||
info.location.region, true)
|
||||
.addField('**Condition:**',
|
||||
info.item.condition.text, true)
|
||||
.addField('**Temperature:**',
|
||||
info.item.condition.temp + "°F", true)
|
||||
.addField('**Humidity:**',
|
||||
info.atmosphere.humidity, true)
|
||||
.addField('**Pressure:**',
|
||||
info.atmosphere.pressure, true)
|
||||
.addField('**Rising:**',
|
||||
info.atmosphere.rising, true)
|
||||
.addField('**Visibility:**',
|
||||
info.atmosphere.visibility, true)
|
||||
.addField('**Wind Chill:**',
|
||||
info.wind.chill, true)
|
||||
.addField('**Wind Direction:**',
|
||||
info.wind.direction, true)
|
||||
.addField('**Wind Speed:**',
|
||||
info.wind.speed, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}).catch(err => {
|
||||
message.channel.send(":x: Error! Make sure you typed the location correctly!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class WikipediaCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'wikipedia',
|
||||
group: 'search',
|
||||
@@ -14,32 +14,33 @@ module.exports = class WikipediaCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||
request
|
||||
.get("https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=" + thingToSearch + "&exintro=&explaintext=&redirects=&formatversion=2")
|
||||
.then(function (response) {
|
||||
let description = response.body.query.pages[0].extract;
|
||||
let name = response.body.query.pages[0].title;
|
||||
thingToSearch = thingToSearch.split(")").join("%29");
|
||||
if(description === undefined) {
|
||||
.get("https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=" + thingToSearch + "&exintro=&explaintext=&redirects=&formatversion=2")
|
||||
.then(function(response) {
|
||||
let description = response.body.query.pages[0].extract;
|
||||
let name = response.body.query.pages[0].title;
|
||||
thingToSearch = thingToSearch.split(")").join("%29");
|
||||
if (description === undefined) {
|
||||
message.channel.send(":x: Error! Entry Not Found!");
|
||||
}
|
||||
else {
|
||||
description = description.substr(0, 1900);
|
||||
description = description.split('\n').join("\n\n");
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(name)
|
||||
.setURL("https://en.wikipedia.org/wiki/" + thingToSearch)
|
||||
.setAuthor("Wikipedia", "https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png")
|
||||
.setDescription(description + " [Read the Rest Here](https://en.wikipedia.org/wiki/" + thingToSearch + ")");
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! Entry Not Found!");
|
||||
} else {
|
||||
description = description.substr(0, 1900);
|
||||
description = description.split('\n').join("\n\n");
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(name)
|
||||
.setURL("https://en.wikipedia.org/wiki/" + thingToSearch)
|
||||
.setAuthor("Wikipedia", "https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png")
|
||||
.setDescription(description + " [Read the Rest Here](https://en.wikipedia.org/wiki/" + thingToSearch + ")");
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! Entry Not Found!");
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+29
-22
@@ -4,7 +4,7 @@ const request = require('superagent');
|
||||
const config = require('../../config.json');
|
||||
|
||||
module.exports = class YouTubeCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'youtube',
|
||||
aliases: [
|
||||
@@ -18,29 +18,36 @@ module.exports = class YouTubeCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let videoToSearch = message.content.split(" ").slice(1).join("-");
|
||||
request
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({ part: 'snippet', type: 'video', maxResults: 1, q: videoToSearch, key: config.youtubekey })
|
||||
.then(function (response) {
|
||||
if(response.body.items[0].snippet === undefined) {
|
||||
message.channel.send(':x: Error! No Video Found!');
|
||||
} else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(response.body.items[0].snippet.title)
|
||||
.setDescription(response.body.items[0].snippet.description)
|
||||
.setAuthor('YouTube - ' + response.body.items[0].snippet.channelTitle, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png')
|
||||
.setURL('https://www.youtube.com/watch?v=' + response.body.items[0].id.videoId)
|
||||
.setThumbnail(response.body.items[0].snippet.thumbnails.default.url);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! An error has occurred! Try again (if this continues to occur, the daily quota may have been reached).");
|
||||
});
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
part: 'snippet',
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: videoToSearch,
|
||||
key: config.youtubekey
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.body.items[0].snippet === undefined) {
|
||||
message.channel.send(':x: Error! No Video Found!');
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(response.body.items[0].snippet.title)
|
||||
.setDescription(response.body.items[0].snippet.description)
|
||||
.setAuthor('YouTube - ' + response.body.items[0].snippet.channelTitle, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png')
|
||||
.setURL('https://www.youtube.com/watch?v=' + response.body.items[0].id.videoId)
|
||||
.setThumbnail(response.body.items[0].snippet.thumbnails.default.url);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! An error has occurred! Try again (if this continues to occur, the daily quota may have been reached).");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
+39
-38
@@ -3,7 +3,7 @@ const Discord = require('discord.js');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class YuGiOhCommand extends commando.Command {
|
||||
constructor(Client){
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'yugioh',
|
||||
group: 'search',
|
||||
@@ -14,45 +14,46 @@ module.exports = class YuGiOhCommand extends commando.Command {
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if(message.channel.type !== 'dm') {
|
||||
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
let cardName = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||
request
|
||||
.get('http://yugiohprices.com/api/card_data/' + cardName)
|
||||
.then(function (response) {
|
||||
if(response.body.data.card_type === 'monster') {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.body.data.card_type, true)
|
||||
.addField('**Species:**',
|
||||
response.body.data.type, true)
|
||||
.addField('**Attribute:**',
|
||||
response.body.data.family, true)
|
||||
.addField('**ATK:**',
|
||||
response.body.data.atk, true)
|
||||
.addField('**DEF:**',
|
||||
response.body.data.def, true)
|
||||
.addField('**Level:**',
|
||||
response.body.data.level, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
} else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.body.data.card_type, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
message.channel.send(":x: Error! Card not Found!\n:notepad_spiral: Note: This command is **extremely** sensitive to casing and dashes and whatnot. Type the *exact* card name to get data!");
|
||||
});
|
||||
.get('http://yugiohprices.com/api/card_data/' + cardName)
|
||||
.then(function(response) {
|
||||
if (response.body.data.card_type === 'monster') {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.body.data.card_type, true)
|
||||
.addField('**Species:**',
|
||||
response.body.data.type, true)
|
||||
.addField('**Attribute:**',
|
||||
response.body.data.family, true)
|
||||
.addField('**ATK:**',
|
||||
response.body.data.atk, true)
|
||||
.addField('**DEF:**',
|
||||
response.body.data.def, true)
|
||||
.addField('**Level:**',
|
||||
response.body.data.level, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558')
|
||||
.addField('**Card Type:**',
|
||||
response.body.data.card_type, true);
|
||||
message.channel.sendEmbed(embed).catch(console.error);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
message.channel.send(":x: Error! Card not Found!\n:notepad_spiral: Note: This command is **extremely** sensitive to casing and dashes and whatnot. Type the *exact* card name to get data!");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user