mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Fix
This commit is contained in:
@@ -52,6 +52,7 @@ module.exports = class MagicCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { query }) {
|
async run(msg, { query }) {
|
||||||
const card = query ? await this.search(query) : await this.random();
|
const card = query ? await this.search(query) : await this.random();
|
||||||
|
if (!card) return msg.say('Could not find any results.');
|
||||||
const isMDFC = Boolean(card.card_faces);
|
const isMDFC = Boolean(card.card_faces);
|
||||||
const oracleText = isMDFC ? card.card_faces.map(c => c.oracle_text).join('\n\n//\n\n') : card.oracle_text;
|
const oracleText = isMDFC ? card.card_faces.map(c => c.oracle_text).join('\n\n//\n\n') : card.oracle_text;
|
||||||
const manaCost = isMDFC ? card.card_faces.map(c => c.mana_cost).join(' // ') : card.mana_cost;
|
const manaCost = isMDFC ? card.card_faces.map(c => c.mana_cost).join(' // ') : card.mana_cost;
|
||||||
@@ -75,7 +76,6 @@ module.exports = class MagicCommand extends Command {
|
|||||||
const { body } = await request
|
const { body } = await request
|
||||||
.get('https://api.scryfall.com/cards/search')
|
.get('https://api.scryfall.com/cards/search')
|
||||||
.query({ q: `${query}${isFunny ? ' is:funny' : ''}` });
|
.query({ q: `${query}${isFunny ? ' is:funny' : ''}` });
|
||||||
if (!body.data || !body.data.length || body.status === 404) return null;
|
|
||||||
return body.data[0];
|
return body.data[0];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 404) return null;
|
if (err.status === 404) return null;
|
||||||
|
|||||||
+34
-29
@@ -37,35 +37,40 @@ module.exports = class YuGiOhCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { card }) {
|
async run(msg, { card }) {
|
||||||
const { body } = await request
|
try {
|
||||||
.get('https://db.ygoprodeck.com/api/v7/cardinfo.php')
|
const { body } = await request
|
||||||
.query({
|
.get('https://db.ygoprodeck.com/api/v7/cardinfo.php')
|
||||||
fname: card,
|
.query({
|
||||||
la: 'english'
|
fname: card,
|
||||||
});
|
la: 'english'
|
||||||
const data = body.data[0];
|
});
|
||||||
const embed = new MessageEmbed()
|
const data = body.data[0];
|
||||||
.setColor(0xBE5F1F)
|
const embed = new MessageEmbed()
|
||||||
.setTitle(data.name)
|
.setColor(0xBE5F1F)
|
||||||
.setURL(`https://db.ygoprodeck.com/card/?search=${data.id}`)
|
.setTitle(data.name)
|
||||||
.setDescription(data.type === 'Normal Monster' ? `_${shorten(data.desc)}_` : shorten(data.desc))
|
.setURL(`https://db.ygoprodeck.com/card/?search=${data.id}`)
|
||||||
.setAuthor('Yu-Gi-Oh!', logos.yugioh, 'http://www.yugioh-card.com/')
|
.setDescription(data.type === 'Normal Monster' ? `_${shorten(data.desc)}_` : shorten(data.desc))
|
||||||
.setThumbnail(data.card_images[0].image_url)
|
.setAuthor('Yu-Gi-Oh!', logos.yugioh, 'http://www.yugioh-card.com/')
|
||||||
.setFooter(data.id.toString())
|
.setThumbnail(data.card_images[0].image_url)
|
||||||
.addField('❯ Type', data.type, true)
|
.setFooter(data.id.toString())
|
||||||
.addField(data.type.includes('Monster') ? '❯ Race' : '❯ Spell Type', data.race, true);
|
.addField('❯ Type', data.type, true)
|
||||||
if (data.type.includes('Monster')) {
|
.addField(data.type.includes('Monster') ? '❯ Race' : '❯ Spell Type', data.race, true);
|
||||||
embed
|
if (data.type.includes('Monster')) {
|
||||||
.addField('❯ Attribute', data.attribute, true)
|
embed
|
||||||
.addField('❯ Level', data.level?.toString() || 'N/A', true)
|
.addField('❯ Attribute', data.attribute, true)
|
||||||
.addField('❯ ATK', formatNumber(data.atk).toString(), true)
|
.addField('❯ Level', data.level?.toString() || 'N/A', true)
|
||||||
.addField(
|
.addField('❯ ATK', formatNumber(data.atk).toString(), true)
|
||||||
data.type === 'Link Monster' ? '❯ Link Value' : '❯ DEF',
|
.addField(
|
||||||
formatNumber(data.type === 'Link Monster' ? data.linkval : data.def).toString(),
|
data.type === 'Link Monster' ? '❯ Link Value' : '❯ DEF',
|
||||||
true
|
formatNumber(data.type === 'Link Monster' ? data.linkval : data.def).toString(),
|
||||||
);
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
embed.addField('❯ TCGPlayer Price', `$${data.card_prices[0].tcgplayer_price}`);
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.status === 400) return msg.say('Could not find any results.');
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
embed.addField('❯ TCGPlayer Price', `$${data.card_prices[0].tcgplayer_price}`);
|
|
||||||
return msg.embed(embed);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user