mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Change in the way Requests work
This commit is contained in:
@@ -27,10 +27,11 @@ module.exports = class QuizCommand extends commando.Command {
|
||||
.query({
|
||||
count: 1
|
||||
});
|
||||
let answer = response.body[0].answer.toLowerCase().split("<i>").join("").split("</i>").join("");
|
||||
let data = response.body[0];
|
||||
let answer = data.answer.toLowerCase().split("<i>").join("").split("</i>").join("");
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle('You have **fifteen** seconds to answer this question:')
|
||||
.setDescription(`**Category: ${response.body[0].category.title}**\n${response.body[0].question}`);
|
||||
.setDescription(`**Category: ${data.category.title}**\n${data.question}`);
|
||||
let embedMsg = await message.embed(embed);
|
||||
try {
|
||||
let collected = await message.channel.awaitMessages(res => res.author.id === message.author.id, {
|
||||
|
||||
@@ -56,7 +56,8 @@ module.exports = class StrawpollCommand extends commando.Command {
|
||||
title: title,
|
||||
options: choices
|
||||
});
|
||||
return message.say(`${response.body.title}\nhttp://strawpoll.me/${response.body.id}`);
|
||||
let data = response.body;
|
||||
return message.say(`${data.title}\nhttp://strawpoll.me/${data.id}`);
|
||||
}
|
||||
catch (err) {
|
||||
return message.say(":x: Error! Something went wrong!");
|
||||
|
||||
@@ -25,18 +25,18 @@ module.exports = class TodayCommand extends commando.Command {
|
||||
let response = await request
|
||||
.get('http://history.muffinlabs.com/date')
|
||||
.set({
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
})
|
||||
.buffer(true);
|
||||
let responseData = JSON.parse(response.text);
|
||||
let randomNumber = Math.floor(Math.random() * responseData.data.Events.length);
|
||||
let parsedResponse = JSON.parse(response.text);
|
||||
let events = parsedResponse.data.Events;
|
||||
let randomNumber = Math.floor(Math.random() * events.length);
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setURL(responseData.url)
|
||||
.setTitle(`On this day (${responseData.date})...`)
|
||||
.setURL(parsedResponse.url)
|
||||
.setTitle(`On this day (${parsedResponse.date})...`)
|
||||
.setTimestamp()
|
||||
.setDescription(`${responseData.data.Events[randomNumber].text} (${responseData.data.Events[randomNumber].year})`);
|
||||
.setDescription(`${events[randomNumber].text} (${events[randomNumber].year})`);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
const commando = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const request = require('superagent');
|
||||
|
||||
module.exports = class AppStoreCommand extends commando.Command {
|
||||
constructor(Client) {
|
||||
super(Client, {
|
||||
name: 'appstore',
|
||||
aliases: [
|
||||
'app-store',
|
||||
'app'
|
||||
],
|
||||
group: 'search',
|
||||
memberName: 'appstore',
|
||||
description: 'Searches the App Store for your query. (;appstore DragonVale)',
|
||||
examples: [';appstore DragonVale'],
|
||||
args: [{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search the App Store for?',
|
||||
type: 'string'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
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 query = args.query;
|
||||
try {
|
||||
let response = await request
|
||||
.get('https://itunes.apple.com/search')
|
||||
.query({
|
||||
term: query,
|
||||
country: 'us',
|
||||
entity: 'software',
|
||||
limit: 1
|
||||
});
|
||||
let parsedResponse = JSON.parse(response.text);
|
||||
let data = parsedResponse.results[0];
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x1BA3F7)
|
||||
.setAuthor('App Store', 'https://upload.wikimedia.org/wikipedia/en/1/1f/App_Store_Logo.png')
|
||||
.setTitle(data.trackName)
|
||||
.setURL(data.trackViewUrl)
|
||||
.setDescription(data.description)
|
||||
.setThumbnail(data.artworkUrl512)
|
||||
.addField('**Version:**',
|
||||
data.version, true)
|
||||
.addField('**Seller:**',
|
||||
data.artistName, true)
|
||||
.addField('**Price:**',
|
||||
`${data.formattedPrice} (USD)`, true)
|
||||
.addField('**Rated:**',
|
||||
data.contentAdvisoryRating, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
return message.say(":x: Error! Something went wrong!");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -35,18 +35,19 @@ module.exports = class BotSearchCommand extends commando.Command {
|
||||
.set({
|
||||
'Authorization': config.botskey
|
||||
});
|
||||
let data = response.body;
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg')
|
||||
.setTitle(response.body.name)
|
||||
.setTitle(data.name)
|
||||
.setURL('https://bots.discord.pw/')
|
||||
.setDescription(response.body.description)
|
||||
.setDescription(data.description)
|
||||
.addField('**Library:**',
|
||||
response.body.library, true)
|
||||
data.library, true)
|
||||
.addField('**Prefix:**',
|
||||
response.body.prefix, true)
|
||||
data.prefix, true)
|
||||
.addField('**Invite:**',
|
||||
`[Here](${response.body.invite_url})`, true);
|
||||
`[Here](${data.invite_url})`, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -41,10 +41,11 @@ module.exports = class DefineCommand extends commando.Command {
|
||||
includeTags: false,
|
||||
api_key: config.wordnikkey
|
||||
});
|
||||
let data = response.body[0];
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(response.body[0].word)
|
||||
.setDescription(response.body[0].text);
|
||||
.setTitle(data.word)
|
||||
.setDescription(data.text);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
+19
-15
@@ -29,27 +29,31 @@ module.exports = class ForecastCommand extends commando.Command {
|
||||
let locationToSearch = args.locationQ;
|
||||
try {
|
||||
let response = await request
|
||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${locationToSearch}")&format=json`);
|
||||
.get('https://query.yahooapis.com/v1/public/yql')
|
||||
.query({
|
||||
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${locationToSearch}")&format=json`
|
||||
});
|
||||
let info = response.body.query.results.channel;
|
||||
let data = info.item.forecast;
|
||||
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}°F, **Low:** ${info.item.forecast[0].low}°F, **Condition:** ${info.item.forecast[0].text}`)
|
||||
.addField(`**${info.item.forecast[1].day} - ${info.item.forecast[1].date}:**`,
|
||||
`**High:** ${info.item.forecast[1].high}°F, **Low:** ${info.item.forecast[1].low}°F, **Condition:** ${info.item.forecast[1].text}`)
|
||||
.addField(`**${info.item.forecast[2].day} - ${info.item.forecast[2].date}:**`,
|
||||
`**High:** ${info.item.forecast[2].high}°F, **Low:** ${info.item.forecast[2].low}°F, **Condition:** ${info.item.forecast[2].text}`)
|
||||
.addField(`**${info.item.forecast[3].day} - ${info.item.forecast[3].date}:**`,
|
||||
`**High:** ${info.item.forecast[3].high}°F, **Low:** ${info.item.forecast[3].low}°F, **Condition:** ${info.item.forecast[3].text}`)
|
||||
.addField(`**${info.item.forecast[4].day} - ${info.item.forecast[4].date}:**`,
|
||||
`**High:** ${info.item.forecast[4].high}°F, **Low:** ${info.item.forecast[4].low}°F, **Condition:** ${info.item.forecast[4].text}`)
|
||||
.addField(`**${info.item.forecast[5].day} - ${info.item.forecast[5].date}:**`,
|
||||
`**High:** ${info.item.forecast[5].high}°F, **Low:** ${info.item.forecast[5].low}°F, **Condition:** ${info.item.forecast[5].text}`)
|
||||
.addField(`**${info.item.forecast[6].day} - ${info.item.forecast[6].date}:**`,
|
||||
`**High:** ${info.item.forecast[6].high}°F, **Low:** ${info.item.forecast[6].low}°F, **Condition:** ${info.item.forecast[6].text}`);
|
||||
.addField(`**${data.day} - ${data.date}:**`,
|
||||
`**High:** ${data[0].high}°F, **Low:** ${data[0].low}°F, **Condition:** ${data[0].text}`)
|
||||
.addField(`**${data[1].day} - ${data[1].date}:**`,
|
||||
`**High:** ${data[1].high}°F, **Low:** ${data[1].low}°F, **Condition:** ${data[1].text}`)
|
||||
.addField(`**${data[2].day} - ${data[2].date}:**`,
|
||||
`**High:** ${data[2].high}°F, **Low:** ${data[2].low}°F, **Condition:** ${data[2].text}`)
|
||||
.addField(`**${data[3].day} - ${data[3].date}:**`,
|
||||
`**High:** ${data[3].high}°F, **Low:** ${data[3].low}°F, **Condition:** ${data[3].text}`)
|
||||
.addField(`**${data[4].day} - ${data[4].date}:**`,
|
||||
`**High:** ${data[4].high}°F, **Low:** ${data[4].low}°F, **Condition:** ${data[4].text}`)
|
||||
.addField(`**${data[5].day} - ${data[5].date}:**`,
|
||||
`**High:** ${data[5].high}°F, **Low:** ${data[5].low}°F, **Condition:** ${data[5].text}`)
|
||||
.addField(`**${data[6].day} - ${data[6].date}:**`,
|
||||
`**High:** ${data[6].high}°F, **Low:** ${data[6].low}°F, **Condition:** ${data[6].text}`);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -27,14 +27,17 @@ module.exports = class GoogleCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let thingToSearch = encodeURI(args.query);
|
||||
let thingToSearch = args.query;
|
||||
let searchMsg = await message.say('Searching...');
|
||||
try {
|
||||
let response = await request
|
||||
.get(`https://www.google.com/search?q=${thingToSearch}`);
|
||||
.get(`https://www.google.com/search`)
|
||||
.query({
|
||||
q: thingToSearch
|
||||
});
|
||||
const $ = cheerio.load(response.text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) return searchMsg.edit(':x: Error! No Results Found!');
|
||||
//if (!href) return searchMsg.edit(':x: Error! No Results Found!');
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
return searchMsg.edit(href.q);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,16 @@ module.exports = class ImageSearchCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let thingToSearch = encodeURI(args.query);
|
||||
let thingToSearch = args.query;
|
||||
let searchMsg = await message.say('Searching...');
|
||||
try {
|
||||
let response = await request
|
||||
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${thingToSearch}`);
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
tbm: 'isch',
|
||||
gs_1: 'img',
|
||||
q: thingToSearch
|
||||
});
|
||||
const $ = cheerio.load(response.text);
|
||||
const result = $('.images_table').find('img').first().attr('src');
|
||||
return searchMsg.edit(result);
|
||||
|
||||
+11
-10
@@ -36,26 +36,27 @@ module.exports = class IMDBCommand extends commando.Command {
|
||||
t: queryMovie,
|
||||
plot: 'full'
|
||||
});
|
||||
let data = response.body;
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xDBA628)
|
||||
.setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png')
|
||||
.setURL(`http://www.imdb.com/title/${response.body.imdbID}`)
|
||||
.setTitle(`${response.body.Title} (${response.body.imdbRating} Score)`)
|
||||
.setDescription(`${response.body.Plot.substr(0, 1500)} [Read the Rest Here!](http://www.imdb.com/title/${response.body.imdbID})`)
|
||||
.setURL(`http://www.imdb.com/title/${data.imdbID}`)
|
||||
.setTitle(`${data.Title} (${data.imdbRating} Score)`)
|
||||
.setDescription(`${data.Plot.substr(0, 1500)} [Read the Rest Here!](http://www.imdb.com/title/${data.imdbID})`)
|
||||
.addField('**Genres:**',
|
||||
response.body.Genre)
|
||||
data.Genre)
|
||||
.addField('**Year:**',
|
||||
response.body.Year, true)
|
||||
data.Year, true)
|
||||
.addField('**Rated:**',
|
||||
response.body.Rated, true)
|
||||
data.Rated, true)
|
||||
.addField('**Runtime:**',
|
||||
response.body.Runtime, true)
|
||||
data.Runtime, true)
|
||||
.addField('**Directors:**',
|
||||
response.body.Director)
|
||||
data.Director)
|
||||
.addField('**Writers:**',
|
||||
response.body.Writer)
|
||||
data.Writer)
|
||||
.addField('**Actors:**',
|
||||
response.body.Actors);
|
||||
data.Actors);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
+13
-12
@@ -38,34 +38,35 @@ module.exports = class OsuCommand extends commando.Command {
|
||||
u: usernameToSearch,
|
||||
type: 'string'
|
||||
});
|
||||
let data = response.body[0];
|
||||
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)
|
||||
data.username, true)
|
||||
.addField('**ID:**',
|
||||
response.body[0].user_id, true)
|
||||
data.user_id, true)
|
||||
.addField('**Level:**',
|
||||
response.body[0].level, true)
|
||||
data.level, true)
|
||||
.addField('**Accuracy**',
|
||||
response.body[0].accuracy, true)
|
||||
data.accuracy, true)
|
||||
.addField('**Rank:**',
|
||||
response.body[0].pp_rank, true)
|
||||
data.pp_rank, true)
|
||||
.addField('**Play Count:**',
|
||||
response.body[0].playcount, true)
|
||||
data.playcount, true)
|
||||
.addField('**Country:**',
|
||||
response.body[0].country, true)
|
||||
data.country, true)
|
||||
.addField('**Ranked Score:**',
|
||||
response.body[0].ranked_score, true)
|
||||
data.ranked_score, true)
|
||||
.addField('**Total Score:**',
|
||||
response.body[0].total_score, true)
|
||||
data.total_score, true)
|
||||
.addField('**SS:**',
|
||||
response.body[0].count_rank_ss, true)
|
||||
data.count_rank_ss, true)
|
||||
.addField('**S:**',
|
||||
response.body[0].count_rank_s, true)
|
||||
data.count_rank_s, true)
|
||||
.addField('**A:**',
|
||||
response.body[0].count_rank_a, true);
|
||||
data.count_rank_a, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -35,14 +35,15 @@ module.exports = class UrbanDictionary extends commando.Command {
|
||||
.query({
|
||||
term: wordToDefine
|
||||
});
|
||||
let data = response.body.list[0];
|
||||
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.body.list[0].permalink)
|
||||
.setTitle(response.body.list[0].word)
|
||||
.setDescription(`${response.body.list[0].definition.substr(0, 1900)} [Read the Rest Here!](${response.body.list[0].permalink})`)
|
||||
.setURL(data.permalink)
|
||||
.setTitle(data.word)
|
||||
.setDescription(`${data.definition.substr(0, 1900)} [Read the Rest Here!](${data.permalink})`)
|
||||
.addField('**Example:**',
|
||||
response.body.list[0].example.substr(0, 1900) || 'None');
|
||||
data.example.substr(0, 1900) || 'None');
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -35,24 +35,25 @@ module.exports = class WattpadCommand extends commando.Command {
|
||||
query: queryBook,
|
||||
limit: 1
|
||||
});
|
||||
let data = response.body.stories[0];
|
||||
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})`)
|
||||
.setURL(data.url)
|
||||
.setTitle(data.title)
|
||||
.setDescription(`${data.description.substr(0, 1500)} [Read the Rest Here!](${data.url})`)
|
||||
.addField('**Author:**',
|
||||
response.body.stories[0].user, true)
|
||||
data.user, true)
|
||||
.addField('**Parts:**',
|
||||
response.body.stories[0].numParts, true)
|
||||
data.numParts, true)
|
||||
.addField('**Created On:**',
|
||||
response.body.stories[0].createDate, true)
|
||||
data.createDate, true)
|
||||
.addField('**Votes:**',
|
||||
response.body.stories[0].voteCount, true)
|
||||
data.voteCount, true)
|
||||
.addField('**Reads:**',
|
||||
response.body.stories[0].readCount, true)
|
||||
data.readCount, true)
|
||||
.addField('**Comments:**',
|
||||
response.body.stories[0].commentCount, true);
|
||||
data.commentCount, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
+19
-16
@@ -26,37 +26,40 @@ module.exports = class WeatherCommand extends commando.Command {
|
||||
let locationToSearch = args.locationQ;
|
||||
try {
|
||||
let response = await request
|
||||
.get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${locationToSearch}")&format=json`);
|
||||
let info = response.body.query.results.channel;
|
||||
.get('https://query.yahooapis.com/v1/public/yql')
|
||||
.query({
|
||||
q: `select * from weather.forecast where u='f' AND woeid in (select woeid from geo.places(1) where text="${locationToSearch}")&format=json`
|
||||
});
|
||||
let data = response.body.query.results.channel;
|
||||
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)
|
||||
.setAuthor(data.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||
.setURL(data.link)
|
||||
.setTimestamp()
|
||||
.addField('**City:**',
|
||||
info.location.city, true)
|
||||
data.location.city, true)
|
||||
.addField('**Country**',
|
||||
info.location.country, true)
|
||||
data.location.country, true)
|
||||
.addField('**Region:**',
|
||||
info.location.region, true)
|
||||
data.location.region, true)
|
||||
.addField('**Condition:**',
|
||||
info.item.condition.text, true)
|
||||
data.item.condition.text, true)
|
||||
.addField('**Temperature:**',
|
||||
`${info.item.condition.temp}°F`, true)
|
||||
`${data.item.condition.temp}°F`, true)
|
||||
.addField('**Humidity:**',
|
||||
info.atmosphere.humidity, true)
|
||||
data.atmosphere.humidity, true)
|
||||
.addField('**Pressure:**',
|
||||
info.atmosphere.pressure, true)
|
||||
data.atmosphere.pressure, true)
|
||||
.addField('**Rising:**',
|
||||
info.atmosphere.rising, true)
|
||||
data.atmosphere.rising, true)
|
||||
.addField('**Visibility:**',
|
||||
info.atmosphere.visibility, true)
|
||||
data.atmosphere.visibility, true)
|
||||
.addField('**Wind Chill:**',
|
||||
info.wind.chill, true)
|
||||
data.wind.chill, true)
|
||||
.addField('**Wind Direction:**',
|
||||
info.wind.direction, true)
|
||||
data.wind.direction, true)
|
||||
.addField('**Wind Speed:**',
|
||||
info.wind.speed, true);
|
||||
data.wind.speed, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -23,22 +23,30 @@ module.exports = class WikipediaCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let thingToSearch = encodeURI(args.query);
|
||||
let thingToSearch = args.query;
|
||||
thingToSearch = thingToSearch.split(")").join("%29");
|
||||
let title = encodeURI(thingToSearch);
|
||||
try {
|
||||
let response = await request
|
||||
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${thingToSearch}&exintro=&explaintext=&redirects=&formatversion=2`);
|
||||
let description = response.body.query.pages[0].extract;
|
||||
let name = response.body.query.pages[0].title;
|
||||
if (!description) return message.say(":x: Error! Entry Not Found!");
|
||||
description = description.substr(0, 1900);
|
||||
description = description.split('\n').join("\n\n");
|
||||
.get(`https://en.wikipedia.org/w/api.php`)
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: thingToSearch,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
let data = response.body.query.pages[0];
|
||||
let description = data.extract.substr(0, 1900).split('\n').join('\n\n');
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(name)
|
||||
.setURL(`https://en.wikipedia.org/wiki/${thingToSearch}`)
|
||||
.setTitle(data.name)
|
||||
.setURL(`https://en.wikipedia.org/wiki/${title}`)
|
||||
.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})`);
|
||||
.setDescription(`${description} [Read the Rest Here](https://en.wikipedia.org/wiki/${title})`);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -38,18 +38,19 @@ module.exports = class YouTubeCommand extends commando.Command {
|
||||
q: videoToSearch,
|
||||
key: config.youtubekey
|
||||
});
|
||||
if (!response.body.items[0].snippet) return message.say(':x: Error! No Video Found!');
|
||||
//if (!response.body.items[0].snippet) return message.say(':x: Error! No Video Found!');
|
||||
let data = response.body.items[0];
|
||||
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);
|
||||
.setTitle(data.snippet.title)
|
||||
.setDescription(data.snippet.description)
|
||||
.setAuthor(`YouTube - ${data.snippet.channelTitle}`, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png')
|
||||
.setURL(`https://www.youtube.com/watch?v=${data.id.videoId}`)
|
||||
.setThumbnail(data.snippet.thumbnails.default.url);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
return message.say(":x: Error! An error has occurred! Try again later! (If this continues to occur, the daily quota may have been reached).");
|
||||
return message.say(":x: Error! Something went wrong! Maybe no video was found?");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+14
-13
@@ -27,33 +27,34 @@ module.exports = class YuGiOhCommand extends commando.Command {
|
||||
try {
|
||||
let response = await request
|
||||
.get(`http://yugiohprices.com/api/card_data/${cardName}`);
|
||||
if (response.body.data.card_type === 'monster') {
|
||||
let data = response.body.data;
|
||||
if (data.card_type === 'monster') {
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setTitle(data.name)
|
||||
.setDescription(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)
|
||||
'Monster', true)
|
||||
.addField('**Type:**',
|
||||
data.type, true)
|
||||
.addField('**Attribute:**',
|
||||
response.body.data.family, true)
|
||||
data.family, true)
|
||||
.addField('**ATK:**',
|
||||
response.body.data.atk, true)
|
||||
data.atk, true)
|
||||
.addField('**DEF:**',
|
||||
response.body.data.def, true)
|
||||
data.def, true)
|
||||
.addField('**Level:**',
|
||||
response.body.data.level, true);
|
||||
data.level, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(response.body.data.name)
|
||||
.setDescription(response.body.data.text)
|
||||
.setTitle(data.name)
|
||||
.setDescription(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);
|
||||
data.card_type, true);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -34,7 +34,6 @@ module.exports = class YodaCommand extends commando.Command {
|
||||
.query({
|
||||
sentence: turnToYoda
|
||||
});
|
||||
if (!response.text) return message.say(':x: Error! Something went wrong! Keep it simple to avoid this error.');
|
||||
return message.say(response.text);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user