Files
xiao/commands/search/yu-gi-oh.js
T
Daniel Odendahl Jr fd4e35533a 23
2017-06-17 03:26:31 +00:00

52 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
module.exports = class YuGiOhCommand extends Command {
constructor(client) {
super(client, {
name: 'yu-gi-oh',
group: 'search',
memberName: 'yu-gi-oh',
description: 'Responds with info on a Yu-Gi-Oh! card.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'query',
prompt: 'What card would you like to get data for?',
type: 'string',
parse: (text) => encodeURIComponent(text)
}
]
});
}
async run(msg, args) {
const { query } = args;
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);
}
};