A simple command to search Scryfall's Magic the Gathering API for specific cards and return the info in a Discord embed message. Once a card is found the message will contain info for: Color, Mana cost, Type, Set, Rarity, Ability text, Flavor text, Price(USD), and Full card image. All you need to get it setup is a Slash command named "mtg" with an additional string option named "card", and you're all set!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let result = context.params.event.data.options[0].value;
let card = result.replace(/ /g, '+'); //Setups the wanted card name for Scryfalls API search
let x = await lib.http.request['@1.1.7'].get({
url: `https://api.scryfall.com/cards/named?exact=${card}`, // GETs the card data from the API
});
await lib.discord.channels['@0.3.2'].messages.create({ //Builds the embed message for response in Discord
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `Magic Card Search`,
description: `**${x.data.name}**`,
color: 0x83008c,
footer: {
text: `${x.data.id}`,
},
thumbnail: {
url: `https://www.theouterhaven.net/wp-content/uploads/2017/11/slider-01.jpg`,
height: 0,
width: 0,
},
fields: [
{
name: `Information & Abilities`,
value: `__**Color:**__ ${x.data.colors}\n
__**Mana cost:**__ ${x.data.mana_cost}\n
__**Type:**__ ${x.data.type_line}\n
__**Set:**__ ${x.data.set_name}\n
__**Rarity:**__ ${x.data.rarity}\n
__**Card Text:**__ ${x.data.oracle_text}\n
__**Flavor Text:**__ ${x.data.flavor_text}\n
__**Price**__ ${x.data.prices.usd}`,
},
],
image: {
url: `${x.data.image_uris.png}`,
height: 0,
width: 0,
},
},
],
});