DiscordPHP-MTG Documentation

CardMessageBuilder extends MessageBuilder
in package

Components V2 messages about one card: the card itself — art, rules text, today's price, its set, and buttons for everything else — and the panels those buttons open (rulings, legality, prices, foreign names, images, JSON).

Buttons carry stable custom ids, routed by the Cards module: card:<action>:<uuid>[:<context>], where the context (page.<search>.<n> or random.<search>) is how the card was reached, kept so the view can offer its way back after a flip or a change of printing.

Tags
see
Cards
since
1.1.0

Table of Contents

Constants

ACCENTS  : array<string, int> = ['W' => 0xf0e6c0, 'U' => 0x2f7fc1, 'B' => 0x5a4...
Accent colors by color identity; several colors are gold.
PREFIX  : string = 'card'
The custom id prefix of every card component.
TEXT_LIMIT  : int = 1500
Budget for the rules text, before mana symbols become emoji.

Methods

accent()  : int
The accent color for the card's color identity.
card()  : static
The card view.
faceImages()  : array<string|int, string>
The image URLs of each face printed on the card.
foreignNames()  : static
The card's names in other languages.
image()  : static
The card's image, both faces of a double-faced card.
json()  : static
The card as MTGJSON JSON, attached as a file (a plain message: files and Components V2 pair badly).
legalities()  : static
Where the card is legal, banned and restricted.
notice()  : static
A short notice, e.g. "nothing found".
panel()  : static
A Components V2 message that mentions nobody.
prices()  : static
Today's prices at every store, retail and buylist.
priceSummary()  : string
Today's main prices in one line: TCGplayer, Card Kingdom and Cardmarket, with foil where there is one.
rulings()  : static
The card's rulings, newest last, grouped by date.
summary()  : string
A one-line summary of the card for lists: name, mana cost, type, set.
detail()  : static
A titled panel about the card.
heading()  : string
"### {identity} Name {mana}", with the face name for one face of a multi-face card.
printingLine()  : string
"-# Set Name (CODE) · #number · Illus. Artist · Language".
printingPicker()  : StringSelect
The other-printings picker; the shown printing is preselected.
quote()  : string
Quotes text, line by line.
rules()  : string
Rules text, then power/toughness, loyalty or defense.
typeLine()  : string
The type line and rarity.

Constants

ACCENTS

Accent colors by color identity; several colors are gold.

public array<string, int> ACCENTS = ['W' => 0xf0e6c0, 'U' => 0x2f7fc1, 'B' => 0x5a4a5e, 'R' => 0xd3402a, 'G' => 0x2e8b4a, 'multicolor' => 0xd4af37, 'colorless' => 0x9ea4a8]

PREFIX

The custom id prefix of every card component.

public string PREFIX = 'card'

TEXT_LIMIT

Budget for the rules text, before mana symbols become emoji.

public int TEXT_LIMIT = 1500

Methods

accent()

The accent color for the card's color identity.

public static accent(Card $card) : int
Parameters
$card : Card
Return values
int

card()

The card view.

public static card(MTG $mtg, Card $card[, array<string|int, array<string|int, mixed>> $printings = [] ][, string $context = '' ][, array<string|int, Button> $navigation = [] ][, string|null $status = null ]) : static
Parameters
$mtg : MTG

For mana symbol emoji.

$card : Card
$printings : array<string|int, array<string|int, mixed>> = []

Other printings of the card for the picker: {uuid, setCode, setName, number, releaseDate}, newest first.

$context : string = ''

How the card was reached (see the class description), or ''.

$navigation : array<string|int, Button> = []

Extra buttons for the last row, e.g. "Back to results".

$status : string|null = null

A line shown above the card.

Return values
static

faceImages()

The image URLs of each face printed on the card.

public static faceImages(Card $card) : array<string|int, string>
Parameters
$card : Card
Return values
array<string|int, string>

foreignNames()

The card's names in other languages.

public static foreignNames(Card $card) : static
Parameters
$card : Card
Return values
static

image()

The card's image, both faces of a double-faced card.

public static image(Card $card) : static
Parameters
$card : Card
Return values
static

json()

The card as MTGJSON JSON, attached as a file (a plain message: files and Components V2 pair badly).

public static json(Card $card) : static
Parameters
$card : Card
Return values
static

legalities()

Where the card is legal, banned and restricted.

public static legalities(Card $card) : static
Parameters
$card : Card
Return values
static

notice()

A short notice, e.g. "nothing found".

public static notice(string $text) : static
Parameters
$text : string
Return values
static

panel()

A Components V2 message that mentions nobody.

public static panel() : static
Return values
static

prices()

Today's prices at every store, retail and buylist.

public static prices(Card $card) : static
Parameters
$card : Card
Return values
static

priceSummary()

Today's main prices in one line: TCGplayer, Card Kingdom and Cardmarket, with foil where there is one.

public static priceSummary(Card $card) : string
Parameters
$card : Card
Return values
string —

Empty when the card has no prices.

rulings()

The card's rulings, newest last, grouped by date.

public static rulings(Card $card) : static
Parameters
$card : Card
Return values
static

summary()

A one-line summary of the card for lists: name, mana cost, type, set.

public static summary(MTG $mtg, Card $card) : string
Parameters
$mtg : MTG
$card : Card
Return values
string

detail()

A titled panel about the card.

protected static detail(Card $card, string $title, string $text) : static
Parameters
$card : Card
$title : string
$text : string
Return values
static

heading()

"### {identity} Name {mana}", with the face name for one face of a multi-face card.

protected static heading(MTG $mtg, Card $card) : string
Parameters
$mtg : MTG
$card : Card
Return values
string

printingLine()

"-# Set Name (CODE) · #number · Illus. Artist · Language".

protected static printingLine(Card $card) : string
Parameters
$card : Card
Return values
string

printingPicker()

The other-printings picker; the shown printing is preselected.

protected static printingPicker(Card $card, array<string|int, array<string|int, mixed>> $printings, string $context) : StringSelect
Parameters
$card : Card
$printings : array<string|int, array<string|int, mixed>>
$context : string
Return values
StringSelect

quote()

Quotes text, line by line.

protected static quote(string $text[, bool $italic = false ]) : string
Parameters
$text : string
$italic : bool = false
Return values
string

rules()

Rules text, then power/toughness, loyalty or defense.

protected static rules(MTG $mtg, Card $card) : string
Parameters
$mtg : MTG
$card : Card
Return values
string

typeLine()

The type line and rarity.

protected static typeLine(Card $card) : string
Parameters
$card : Card
Return values
string
On this page

Search results