mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Fix yu-gi-oh
This commit is contained in:
+16
-22
@@ -2,7 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { shorten } = require('../../util/Util');
|
const { shorten, firstUpperCase } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class YuGiOhCommand extends Command {
|
module.exports = class YuGiOhCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -17,7 +17,8 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'card',
|
key: 'card',
|
||||||
prompt: 'What card would you like to get information on?',
|
prompt: 'What card would you like to get information on?',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
parse: card => encodeURIComponent(card)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -25,33 +26,26 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { card }) {
|
async run(msg, { card }) {
|
||||||
try {
|
try {
|
||||||
const { text } = await request
|
const { body } = await request.get(`https://yugiohprices.com/api/card_data/${card}`);
|
||||||
.get('https://www.ygohub.com/api/card_info')
|
if (body.status === 'fail') return msg.say('Could not find any results.');
|
||||||
.query({ name: card });
|
const image = await request.get(`https://yugiohprices.com/api/card_image/${card}`);
|
||||||
const body = JSON.parse(text);
|
const { data } = body;
|
||||||
if (body.status === 'error') return msg.say('Could not find any results.');
|
|
||||||
const data = body.card;
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
|
.attachFiles([{ attachment: image.body, name: 'thumbnail.jpg' }])
|
||||||
.setColor(0xBE5F1F)
|
.setColor(0xBE5F1F)
|
||||||
.setTitle(data.name)
|
.setTitle(data.name)
|
||||||
.setDescription(shorten(data.text))
|
.setDescription(shorten(data.text))
|
||||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png', 'http://www.yugioh-card.com/')
|
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png', 'http://www.yugioh-card.com/')
|
||||||
.setURL(data.tcgplayer_link)
|
.setThumbnail('attachment://thumbnail.jpg')
|
||||||
.setThumbnail(data.image_path)
|
.addField('❯ Card Type', firstUpperCase(data.card_type), true);
|
||||||
.addField('❯ Card Type', data.type, true);
|
if (data.card_type === 'monster') {
|
||||||
if (data.is_monster) {
|
|
||||||
embed
|
embed
|
||||||
.addField('❯ Species', data.species, true)
|
.addField('❯ Species', data.type, true)
|
||||||
.addField('❯ Attribute', data.attribute, true)
|
.addField('❯ Attribute', firstUpperCase(data.family), true)
|
||||||
.addField('❯ Level', data.stars, true)
|
.addField('❯ Level', data.level, true)
|
||||||
.addField('❯ ATK', data.attack, true)
|
.addField('❯ ATK', data.atk, true)
|
||||||
.addField('❯ DEF', data.defense, true);
|
.addField('❯ DEF', data.def, true);
|
||||||
}
|
}
|
||||||
embed.addField('❯ Legality', stripIndents`
|
|
||||||
TCG Advanced: ${data.legality.TCG.Advanced}
|
|
||||||
TCG Traditional: ${data.legality.TCG.Traditional}
|
|
||||||
OCG Advanced: ${data.legality.OCG.Advanced}
|
|
||||||
`);
|
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "91.0.0",
|
"version": "91.0.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user