mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 22:27:44 +02:00
22.0.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { cleanXML } = require('../../util/Util');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
@@ -32,14 +33,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
q: query
|
||||
});
|
||||
const { anime } = await xml.parseStringAsync(text);
|
||||
const synopsis = anime.entry[0].synopsis[0].substr(0, 2000)
|
||||
.replace(/(<br \/>)/g, '')
|
||||
.replace(/(')/g, '\'')
|
||||
.replace(/(—)/g, '—')
|
||||
.replace(/(")/g, '"')
|
||||
.replace(/(&)/g, '&')
|
||||
.replace(/(")/g, '"')
|
||||
.replace(/(\[i\]|\[\/i\])/g, '*');
|
||||
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2000));
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
|
||||
@@ -47,17 +41,17 @@ module.exports = class AnimeCommand extends Command {
|
||||
.setThumbnail(anime.entry[0].image[0])
|
||||
.setTitle(`${anime.entry[0].title[0]} (English: ${anime.entry[0].english[0] || 'N/A'})`)
|
||||
.setDescription(synopsis)
|
||||
.addField('Type',
|
||||
.addField('❯ Type',
|
||||
`${anime.entry[0].type[0]} - ${anime.entry[0].status[0]}`, true)
|
||||
.addField('Episodes',
|
||||
.addField('❯ Episodes',
|
||||
anime.entry[0].episodes[0], true)
|
||||
.addField('Start Date',
|
||||
.addField('❯ Start Date',
|
||||
anime.entry[0].start_date[0], true)
|
||||
.addField('End Date',
|
||||
.addField('❯ End Date',
|
||||
anime.entry[0].end_date[0], true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('Error: No Results.');
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,22 +26,24 @@ module.exports = class BotSearchCommand extends Command {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://bots.discord.pw/api/bots/${bot.id}`)
|
||||
.set({ Authorization: DBOTS_KEY });
|
||||
.set({
|
||||
Authorization: DBOTS_KEY
|
||||
});
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
|
||||
.setTitle(body.name)
|
||||
.setURL(`https://bots.discord.pw/bots/${bot.id}`)
|
||||
.setDescription(body.description)
|
||||
.addField('Library',
|
||||
.addField('❯ Library',
|
||||
body.library, true)
|
||||
.addField('Invite',
|
||||
.addField('❯ Invite',
|
||||
`[Here](${body.invite_url})`, true)
|
||||
.addField('Prefix',
|
||||
.addField('❯ Prefix',
|
||||
body.prefix, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,28 +23,26 @@ module.exports = class BulbapediaCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://bulbapedia.bulbagarden.net/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: query,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x3E7614)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
.setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png')
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('http://bulbapedia.bulbagarden.net/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: query,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x3E7614)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
.setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png')
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,18 +22,15 @@ module.exports = class DanbooruCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://danbooru.donmai.us/posts.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
if (!body[0].file_url) throw new Error('No Results.');
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://danbooru.donmai.us/posts.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length || !body[0].file_url) {
|
||||
return msg.say('No Results');
|
||||
}
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https://danbooru.donmai.us${body[0].file_url}`);
|
||||
}
|
||||
};
|
||||
|
||||
+16
-18
@@ -16,7 +16,7 @@ module.exports = class DefineCommand extends Command {
|
||||
key: 'query',
|
||||
prompt: 'What would you like to define?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
parse: (query) => encodeURIComponent(query)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -24,23 +24,21 @@ module.exports = class DefineCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`)
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
useCanonical: false,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(body[0].word)
|
||||
.setDescription(body[0].text);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions`)
|
||||
.query({
|
||||
limit: 1,
|
||||
includeRelated: false,
|
||||
useCanonical: false,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(body[0].word)
|
||||
.setDescription(body[0].text);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,9 +15,13 @@ module.exports = class DiscrimCommand extends Command {
|
||||
key: 'discrim',
|
||||
prompt: 'Which discriminator would you like to search for?',
|
||||
type: 'string',
|
||||
validate: discrim => {
|
||||
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
|
||||
return `${discrim} is not a valid discriminator.`;
|
||||
default: '',
|
||||
validate: (discrim) => {
|
||||
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Discriminator.';
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -25,8 +29,8 @@ module.exports = class DiscrimCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { discrim } = args;
|
||||
const users = this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort();
|
||||
const discrim = args.discrim || msg.author.discriminator;
|
||||
const users = this.client.users.filter((u) => u.discriminator === discrim).map((u) => u.username);
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${users.length} Users with the discriminator: ${discrim}`)
|
||||
.setDescription(users.join(', '));
|
||||
|
||||
+29
-31
@@ -22,37 +22,35 @@ module.exports = class ForecastCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.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="${query}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) throw new Error('Location Not Found.');
|
||||
const forecasts = body.query.results.channel.item.forecast;
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField(`${forecasts[0].day} - ${forecasts[0].date}`,
|
||||
`**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`)
|
||||
.addField(`${forecasts[1].day} - ${forecasts[1].date}`,
|
||||
`**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`)
|
||||
.addField(`${forecasts[2].day} - ${forecasts[2].date}`,
|
||||
`**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`)
|
||||
.addField(`${forecasts[3].day} - ${forecasts[3].date}`,
|
||||
`**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`)
|
||||
.addField(`${forecasts[4].day} - ${forecasts[4].date}`,
|
||||
`**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`)
|
||||
.addField(`${forecasts[5].day} - ${forecasts[5].date}`,
|
||||
`**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`)
|
||||
.addField(`${forecasts[6].day} - ${forecasts[6].date}`,
|
||||
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.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="${query}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) {
|
||||
return msg.say('Location Not Found.');
|
||||
}
|
||||
const forecasts = body.query.results.channel.item.forecast;
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField(`❯ ${forecasts[0].day} - ${forecasts[0].date}`,
|
||||
`**High:** ${forecasts[0].high}°F, **Low:** ${forecasts[0].low}°F, **Condition:** ${forecasts[0].text}`)
|
||||
.addField(`❯ ${forecasts[1].day} - ${forecasts[1].date}`,
|
||||
`**High:** ${forecasts[1].high}°F, **Low:** ${forecasts[1].low}°F, **Condition:** ${forecasts[1].text}`)
|
||||
.addField(`❯ ${forecasts[2].day} - ${forecasts[2].date}`,
|
||||
`**High:** ${forecasts[2].high}°F, **Low:** ${forecasts[2].low}°F, **Condition:** ${forecasts[2].text}`)
|
||||
.addField(`❯ ${forecasts[3].day} - ${forecasts[3].date}`,
|
||||
`**High:** ${forecasts[3].high}°F, **Low:** ${forecasts[3].low}°F, **Condition:** ${forecasts[3].text}`)
|
||||
.addField(`❯ ${forecasts[4].day} - ${forecasts[4].date}`,
|
||||
`**High:** ${forecasts[4].high}°F, **Low:** ${forecasts[4].low}°F, **Condition:** ${forecasts[4].text}`)
|
||||
.addField(`❯ ${forecasts[5].day} - ${forecasts[5].date}`,
|
||||
`**High:** ${forecasts[5].high}°F, **Low:** ${forecasts[5].low}°F, **Condition:** ${forecasts[5].text}`)
|
||||
.addField(`❯ ${forecasts[6].day} - ${forecasts[6].date}`,
|
||||
`**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@ module.exports = class GelbooruCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('https://gelbooru.com/index.php')
|
||||
.query({
|
||||
@@ -34,10 +33,9 @@ module.exports = class GelbooruCommand extends Command {
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') throw new Error('No Results.');
|
||||
if (posts.$.count === '0') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+11
-13
@@ -21,19 +21,17 @@ module.exports = class GiphyCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.giphy.com/v1/gifs/search')
|
||||
.query({
|
||||
q: query,
|
||||
api_key: GIPHY_KEY,
|
||||
rating: msg.channel.nsfw ? 'r' : 'pg'
|
||||
});
|
||||
if (!body.data.length) throw new Error('No Results.');
|
||||
const random = Math.floor(Math.random() * body.data.length);
|
||||
return msg.say(body.data[random].images.original.url);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.giphy.com/v1/gifs/search')
|
||||
.query({
|
||||
q: query,
|
||||
api_key: GIPHY_KEY,
|
||||
rating: msg.channel.nsfw ? 'r' : 'pg'
|
||||
});
|
||||
if (!body.data.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const random = Math.floor(Math.random() * body.data.length);
|
||||
return msg.say(body.data[random].images.original.url);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,21 +34,21 @@ module.exports = class GithubCommand extends Command {
|
||||
.setTitle(body.full_name)
|
||||
.setDescription(body.description)
|
||||
.setThumbnail(body.owner.avatar_url)
|
||||
.addField('Creation Date',
|
||||
.addField('❯ Creation Date',
|
||||
moment(body.created_at).format('MMMM Do YYYY'), true)
|
||||
.addField('Last Updated On',
|
||||
.addField('❯ Last Updated On',
|
||||
moment(body.updated_at).format('MMMM Do YYYY'), true)
|
||||
.addField('Stargazers',
|
||||
.addField('❯ Stargazers',
|
||||
body.stargazers_count, true)
|
||||
.addField('Watchers',
|
||||
.addField('❯ Watchers',
|
||||
body.watchers_count, true)
|
||||
.addField('Open Issues',
|
||||
.addField('❯ Open Issues',
|
||||
body.open_issues_count, true)
|
||||
.addField('Language',
|
||||
.addField('❯ Language',
|
||||
body.language, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
return msg.say(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+11
-13
@@ -23,19 +23,17 @@ module.exports = class GoogleCommand extends Command {
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const message = await msg.say('Searching...');
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) throw new Error('No Results.');
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
return message.edit(href.q);
|
||||
} catch (err) {
|
||||
return message.edit(`${err.name}: ${err.message}`);
|
||||
const { text } = await snekfetch
|
||||
.get('https://www.google.com/search')
|
||||
.query({
|
||||
q: query
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
let href = $('.r').first().find('a').first().attr('href');
|
||||
if (!href) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
href = querystring.parse(href.replace('/url?', ''));
|
||||
return message.edit(href.q);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,17 +22,15 @@ module.exports = class KonachanCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://konachan.net/post.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://konachan.net/post.json')
|
||||
.query({
|
||||
tags: `${query ? `${query} ` : ''}order:random`,
|
||||
limit: 1
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`${query ? `Result for ${query}:` : 'Random Image:'} https:${body[0].file_url}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = class LMGTFYCommand extends Command {
|
||||
key: 'query',
|
||||
prompt: 'What would you like to the link to search for?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
parse: (query) => encodeURIComponent(query)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { cleanXML } = require('../../util/Util');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
@@ -32,14 +33,7 @@ module.exports = class MangaCommand extends Command {
|
||||
q: query
|
||||
});
|
||||
const { manga } = await xml.parseStringAsync(text);
|
||||
const synopsis = manga.entry[0].synopsis[0].substr(0, 2000)
|
||||
.replace(/(<br \/>)/g, '')
|
||||
.replace(/(')/g, '\'')
|
||||
.replace(/(—)/g, '—')
|
||||
.replace(/(")/g, '"')
|
||||
.replace(/(&)/g, '&')
|
||||
.replace(/(")/g, '"')
|
||||
.replace(/(\[i\]|\[\/i\])/g, '*');
|
||||
const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2000));
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
|
||||
@@ -47,17 +41,17 @@ module.exports = class MangaCommand extends Command {
|
||||
.setThumbnail(manga.entry[0].image[0])
|
||||
.setTitle(`${manga.entry[0].title[0]} (English: ${manga.entry[0].english[0] || 'N/A'})`)
|
||||
.setDescription(synopsis)
|
||||
.addField('Type',
|
||||
.addField('❯ Type',
|
||||
`${manga.entry[0].type[0]} - ${manga.entry[0].status[0]}`, true)
|
||||
.addField('Volumes / Chapters',
|
||||
.addField('❯ Volumes / Chapters',
|
||||
`${manga.entry[0].volumes[0]} / ${manga.entry[0].chapters[0]}`, true)
|
||||
.addField('Start Date',
|
||||
.addField('❯ Start Date',
|
||||
manga.entry[0].start_date[0], true)
|
||||
.addField('End Date',
|
||||
.addField('❯ End Date',
|
||||
manga.entry[0].end_date[0], true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say('Error: No Results.');
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+14
-17
@@ -16,10 +16,12 @@ module.exports = class MapCommand extends Command {
|
||||
label: 'zoom level',
|
||||
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
|
||||
type: 'integer',
|
||||
validate: zoom => {
|
||||
if (zoom < 21 && zoom > 0)
|
||||
validate: (zoom) => {
|
||||
if (zoom < 21 && zoom > 0) {
|
||||
return true;
|
||||
return 'Please enter a zoom value from 1-20';
|
||||
} else {
|
||||
return 'Please enter a zoom value from 1-20';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -33,19 +35,14 @@ module.exports = class MapCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { zoom, query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: query,
|
||||
zoom,
|
||||
size: '500x500',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
return msg.say({ files: [{ attachment: body, name: 'map.png' }] })
|
||||
.catch(err => msg.say(`${err.name}: ${err.message}`));
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.get('https://maps.googleapis.com/maps/api/staticmap')
|
||||
.query({
|
||||
center: query,
|
||||
zoom,
|
||||
size: '500x500',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
return msg.say({ files: [{ attachment: body, name: 'map.png' }] });
|
||||
}
|
||||
};
|
||||
|
||||
+12
-14
@@ -21,20 +21,18 @@ module.exports = class NeopetCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||
.query({
|
||||
name: query,
|
||||
size: 5,
|
||||
mood: 1
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
const link = $('textarea').first().text();
|
||||
if (!link.includes('cp')) throw new Error('Invalid Pet Name.');
|
||||
return msg.say(link);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { text } = await snekfetch
|
||||
.get('http://www.sunnyneo.com/petimagefinder.php')
|
||||
.query({
|
||||
name: query,
|
||||
size: 5,
|
||||
mood: 1
|
||||
});
|
||||
const $ = cheerio.load(text);
|
||||
const link = $('textarea').first().text();
|
||||
if (!link.includes('cp')) {
|
||||
return msg.say('Invalid Pet Name.');
|
||||
}
|
||||
return msg.say(link);
|
||||
}
|
||||
};
|
||||
|
||||
+38
-40
@@ -23,46 +23,44 @@ module.exports = class OsuCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({
|
||||
k: OSU_KEY,
|
||||
u: query,
|
||||
type: 'string'
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
||||
.setURL('https://osu.ppy.sh/')
|
||||
.addField('Username',
|
||||
body[0].username, true)
|
||||
.addField('ID',
|
||||
body[0].user_id, true)
|
||||
.addField('Level',
|
||||
body[0].level, true)
|
||||
.addField('Accuracy',
|
||||
body[0].accuracy, true)
|
||||
.addField('Rank',
|
||||
body[0].pp_rank, true)
|
||||
.addField('Play Count',
|
||||
body[0].playcount, true)
|
||||
.addField('Country',
|
||||
body[0].country, true)
|
||||
.addField('Ranked Score',
|
||||
body[0].ranked_score, true)
|
||||
.addField('Total Score',
|
||||
body[0].total_score, true)
|
||||
.addField('SS',
|
||||
body[0].count_rank_ss, true)
|
||||
.addField('S',
|
||||
body[0].count_rank_s, true)
|
||||
.addField('A',
|
||||
body[0].count_rank_a, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://osu.ppy.sh/api/get_user')
|
||||
.query({
|
||||
k: OSU_KEY,
|
||||
u: query,
|
||||
type: 'string'
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
||||
.setURL('https://osu.ppy.sh/')
|
||||
.addField('❯ Username',
|
||||
body[0].username, true)
|
||||
.addField('❯ ID',
|
||||
body[0].user_id, true)
|
||||
.addField('❯ Level',
|
||||
body[0].level, true)
|
||||
.addField('❯ Accuracy',
|
||||
body[0].accuracy, true)
|
||||
.addField('❯ Rank',
|
||||
body[0].pp_rank, true)
|
||||
.addField('❯ Play Count',
|
||||
body[0].playcount, true)
|
||||
.addField('❯ Country',
|
||||
body[0].country, true)
|
||||
.addField('❯ Ranked Score',
|
||||
body[0].ranked_score, true)
|
||||
.addField('❯ Total Score',
|
||||
body[0].total_score, true)
|
||||
.addField('❯ SS',
|
||||
body[0].count_rank_ss, true)
|
||||
.addField('❯ S',
|
||||
body[0].count_rank_s, true)
|
||||
.addField('❯ A',
|
||||
body[0].count_rank_a, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+13
-15
@@ -23,21 +23,19 @@ module.exports = class Rule34Command extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('https://rule34.xxx/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') throw new Error('No Results.');
|
||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { text } = await snekfetch
|
||||
.get('https://rule34.xxx/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query,
|
||||
limit: 1
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
if (posts.$.count === '0') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,33 +23,31 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.soundcloud.com/tracks')
|
||||
.query({
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
});
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF15A22)
|
||||
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
|
||||
.setTitle(body[0].title)
|
||||
.setURL(body[0].permalink_url)
|
||||
.setThumbnail(body[0].artwork_url)
|
||||
.addField('Artist',
|
||||
body[0].user.username)
|
||||
.addField('Download Count',
|
||||
body[0].download_count, true)
|
||||
.addField('Comment Count',
|
||||
body[0].comment_count, true)
|
||||
.addField('Playback Count',
|
||||
body[0].playback_count, true)
|
||||
.addField('Favorited Count',
|
||||
body[0].favoritings_count, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.soundcloud.com/tracks')
|
||||
.query({
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
});
|
||||
if (!body.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF15A22)
|
||||
.setAuthor('SoundCloud', 'https://i.imgur.com/lFIz7RU.png')
|
||||
.setTitle(body[0].title)
|
||||
.setURL(body[0].permalink_url)
|
||||
.setThumbnail(body[0].artwork_url)
|
||||
.addField('❯ Artist',
|
||||
body[0].user.username)
|
||||
.addField('❯ Download Count',
|
||||
body[0].download_count, true)
|
||||
.addField('❯ Comment Count',
|
||||
body[0].comment_count, true)
|
||||
.addField('❯ Playback Count',
|
||||
body[0].playback_count, true)
|
||||
.addField('❯ Favorited Count',
|
||||
body[0].favoritings_count, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+16
-18
@@ -22,24 +22,22 @@ module.exports = class UrbanCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.urbandictionary.com/v0/define')
|
||||
.query({
|
||||
term: query
|
||||
});
|
||||
if (!body.list.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
||||
.setURL(body.list[0].permalink)
|
||||
.setTitle(body.list[0].word)
|
||||
.setDescription(body.list[0].definition.substr(0, 2000))
|
||||
.addField('Example',
|
||||
body.list[0].example.substr(0, 2000) || 'None');
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.urbandictionary.com/v0/define')
|
||||
.query({
|
||||
term: query
|
||||
});
|
||||
if (!body.list.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
||||
.setURL(body.list[0].permalink)
|
||||
.setTitle(body.list[0].word)
|
||||
.setDescription(body.list[0].definition.substr(0, 2000))
|
||||
.addField('❯ Example',
|
||||
body.list[0].example.substr(0, 2000) || 'None');
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+31
-31
@@ -24,37 +24,37 @@ module.exports = class WattpadCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
})
|
||||
.set({ Authorization: `Basic ${WATTPAD_KEY}` });
|
||||
if (!body.stories.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
||||
.setURL(body.stories[0].url)
|
||||
.setTitle(body.stories[0].title)
|
||||
.setDescription(body.stories[0].description.substr(0, 2000))
|
||||
.setThumbnail(body.stories[0].cover)
|
||||
.addField('Created On',
|
||||
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
|
||||
.addField('Author',
|
||||
body.stories[0].user, true)
|
||||
.addField('Parts',
|
||||
body.stories[0].numParts, true)
|
||||
.addField('Reads',
|
||||
body.stories[0].readCount, true)
|
||||
.addField('Votes',
|
||||
body.stories[0].voteCount, true)
|
||||
.addField('Comments',
|
||||
body.stories[0].commentCount, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.wattpad.com:443/v4/stories')
|
||||
.query({
|
||||
query,
|
||||
limit: 1
|
||||
})
|
||||
.set({
|
||||
Authorization: `Basic ${WATTPAD_KEY}`
|
||||
});
|
||||
if (!body.stories.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
||||
.setURL(body.stories[0].url)
|
||||
.setTitle(body.stories[0].title)
|
||||
.setDescription(body.stories[0].description.substr(0, 2000))
|
||||
.setThumbnail(body.stories[0].cover)
|
||||
.addField('❯ Created On',
|
||||
moment(body.stories[0].createDate).format('MMMM Do YYYY'), true)
|
||||
.addField('❯ Author',
|
||||
body.stories[0].user, true)
|
||||
.addField('❯ Parts',
|
||||
body.stories[0].numParts, true)
|
||||
.addField('❯ Reads',
|
||||
body.stories[0].readCount, true)
|
||||
.addField('❯ Votes',
|
||||
body.stories[0].voteCount, true)
|
||||
.addField('❯ Comments',
|
||||
body.stories[0].commentCount, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+38
-40
@@ -22,46 +22,44 @@ module.exports = class WeatherCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.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="${query}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) throw new Error('Location Not Found.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField('City',
|
||||
body.query.results.channel.location.city, true)
|
||||
.addField('Country',
|
||||
body.query.results.channel.location.country, true)
|
||||
.addField('Region',
|
||||
body.query.results.channel.location.region, true)
|
||||
.addField('Condition',
|
||||
body.query.results.channel.item.condition.text, true)
|
||||
.addField('Temperature',
|
||||
`${body.query.results.channel.item.condition.temp}°F`, true)
|
||||
.addField('Humidity',
|
||||
body.query.results.channel.atmosphere.humidity, true)
|
||||
.addField('Pressure',
|
||||
body.query.results.channel.atmosphere.pressure, true)
|
||||
.addField('Rising',
|
||||
body.query.results.channel.atmosphere.rising, true)
|
||||
.addField('Visibility',
|
||||
body.query.results.channel.atmosphere.visibility, true)
|
||||
.addField('Wind Chill',
|
||||
body.query.results.channel.wind.chill, true)
|
||||
.addField('Wind Direction',
|
||||
body.query.results.channel.wind.direction, true)
|
||||
.addField('Wind Speed',
|
||||
body.query.results.channel.wind.speed, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.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="${query}")`,
|
||||
format: 'json'
|
||||
});
|
||||
if (!body.query.count) {
|
||||
return msg.say('Location Not Found.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField('❯ City',
|
||||
body.query.results.channel.location.city, true)
|
||||
.addField('❯ Country',
|
||||
body.query.results.channel.location.country, true)
|
||||
.addField('❯ Region',
|
||||
body.query.results.channel.location.region, true)
|
||||
.addField('❯ Condition',
|
||||
body.query.results.channel.item.condition.text, true)
|
||||
.addField('❯ Temperature',
|
||||
`${body.query.results.channel.item.condition.temp}°F`, true)
|
||||
.addField('❯ Humidity',
|
||||
body.query.results.channel.atmosphere.humidity, true)
|
||||
.addField('❯ Pressure',
|
||||
body.query.results.channel.atmosphere.pressure, true)
|
||||
.addField('❯ Rising',
|
||||
body.query.results.channel.atmosphere.rising, true)
|
||||
.addField('❯ Visibility',
|
||||
body.query.results.channel.atmosphere.visibility, true)
|
||||
.addField('❯ Wind Chill',
|
||||
body.query.results.channel.wind.chill, true)
|
||||
.addField('❯ Wind Direction',
|
||||
body.query.results.channel.wind.direction, true)
|
||||
.addField('❯ Wind Speed',
|
||||
body.query.results.channel.wind.speed, true);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,28 +22,26 @@ module.exports = class WikipediaCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://en.wikipedia.org/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: query,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://en.wikipedia.org/w/api.php')
|
||||
.query({
|
||||
action: 'query',
|
||||
prop: 'extracts',
|
||||
format: 'json',
|
||||
titles: query,
|
||||
exintro: '',
|
||||
explaintext: '',
|
||||
redirects: '',
|
||||
formatversion: 2
|
||||
});
|
||||
if (body.query.pages[0].missing) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+19
-21
@@ -23,27 +23,25 @@ module.exports = class YouTubeCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
part: 'snippet',
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: query,
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(body.items[0].snippet.title)
|
||||
.setDescription(body.items[0].snippet.description)
|
||||
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png')
|
||||
.setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`)
|
||||
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get('https://www.googleapis.com/youtube/v3/search')
|
||||
.query({
|
||||
part: 'snippet',
|
||||
type: 'video',
|
||||
maxResults: 1,
|
||||
q: query,
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(body.items[0].snippet.title)
|
||||
.setDescription(body.items[0].snippet.description)
|
||||
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png')
|
||||
.setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`)
|
||||
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
+26
-27
@@ -15,7 +15,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
key: 'query',
|
||||
prompt: 'What card would you like to get data for?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
parse: (text) => encodeURIComponent(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -23,32 +23,31 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||
if (body.status === 'fail') throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.addField('Card Type',
|
||||
body.data.card_type, true);
|
||||
if (body.data.card_type === 'monster') {
|
||||
embed.addField('Type',
|
||||
body.data.type, true)
|
||||
.addField('Attribute',
|
||||
body.data.family, true)
|
||||
.addField('ATK',
|
||||
body.data.atk, true)
|
||||
.addField('DEF',
|
||||
body.data.def, true)
|
||||
.addField('Level',
|
||||
body.data.level, true);
|
||||
}
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const { body } = await snekfetch
|
||||
.get(`http://yugiohprices.com/api/card_data/${query}`);
|
||||
if (body.status === 'fail') {
|
||||
return msg.say('No Results.');
|
||||
}
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.addField('❯ Card Type',
|
||||
body.data.card_type, true);
|
||||
if (body.data.card_type === 'monster') {
|
||||
embed
|
||||
.addField('❯ Type',
|
||||
body.data.type, true)
|
||||
.addField('❯ Attribute',
|
||||
body.data.family, true)
|
||||
.addField('❯ ATK',
|
||||
body.data.atk, true)
|
||||
.addField('❯ DEF',
|
||||
body.data.def, true)
|
||||
.addField('❯ Level',
|
||||
body.data.level, true);
|
||||
}
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user