A simple command to pull a random Magic the Gathering card from Scryfalls API. When 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 set it up is have a command named "mtgrandom"!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let x = await lib.http.request['@1.1.7'].get({
url: `https://api.scryfall.com/cards/random`,
});
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `Random Magic Card`,
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
__**Game**__ ${x.data.games}\n
__**Price**__ ${x.data.prices.usd}`,
},
],
image: {
url: `${x.data.image_uris.png}`,
height: 0,
width: 0,
},
},
],
});