Repository navigation
Releases: Valgorithms/DiscordPHP-MTG
Release list
v1.1.0
The bot is rebuilt like Tutelar: slash and right-click commands, Components V2 messages, and today's card prices.
Commands
| Command | What it does |
|---|---|
/card show <name> [set] |
A card: art, rules text, today's price and its set, with buttons for rulings, legality, prices, foreign names, the full image and JSON, Flip for double-faced cards, a printing picker, and links to Scryfall, EDHREC, TCGplayer, Card Kingdom and Cardmarket. |
/card search … |
Cards by name, type, rules text, colors, color identity, mana value, rarity, set, format legality, keyword, artist, power and toughness, in pages; open one, then Back to results. |
/card random [filters] |
A random card, with 🎲 Another. |
/card prices <name> [set] |
Today's retail and buylist prices at TCGplayer, Card Kingdom, Cardmarket, Mana Pool and Cardhoarder. |
/set show · /set search |
A set's size, dates and boosters, with Browse cards, Open a booster and Decks. |
/booster <set> [type] |
Open a pack with the real product's odds, its value, Images and Open another. |
/deck show · /deck search |
Preconstructed decks by card type, with Export decklist for MTG Arena and deck sites. |
| Find cards (right-click a message) | Looks up every [[Card Name]] in it. Inline [[...]] replies are opt-in with MTG_INLINE_LOOKUPS=1 (needs the Message Content intent). |
/help · /about · /invite · /ping |
Guide, data freshness, install links, latency. |
/card_search still works as before. Names, sets, keywords and formats autocomplete; every command takes hidden:true.
How it works
- Features are modules (
MTG\Modules\*), booted once the gateway and the application are ready. Each declares its commands, andMTG::defineCommand()creates missing ones and re-registers changed ones, so command edits now reach Discord. - Buttons and pickers carry stable custom ids routed by one listener per module, so they keep working after a restart.
- Messages are
MessageBuildersubclasses inMTG\Builders, tested against Discord's limits on hundreds of real cards, sets, boosters and decks.
Prices
MTGJSON's daily price file takes about 1 GB to decode, so the new prices workflow turns it into a 12 MB SQLite file each day and publishes it on the prices release. The bot downloads that (~5 MB gzipped) and refreshes it daily; MTG_PRICES=0 turns it off. Cards carry prices, read with Card::getPrice().
Library additions
CardRepository::countCards(),getPrintings();getCards(['unique' => true])for one printing per card.SetRepository::countSets(),countDecks(); set searches takeyear.MTG::addModule(),defineCommand(),getPriceDatabase(),getSuggestions(),getSearchCache().
Fixed
- DiscordPHP's bootstrap client could announce
application-initbefore the MTG client had the application, so commands could be registered against an unbound application id. - Set filters that tell a code from a name now wait for the card build to open.
Deprecated
Card::toContainer()and theCard::get*Button()helpers; useMTG\Builders\CardMessageBuilder.
Removed
bot.php's HTTP listener on port 55555, which was never attached to its socket and never answered (http_portis gone fromenv.example).
Full Changelog: v1.0.0...v1.1.0
v1.0.0
DiscordPHP-MTG now gets its card data from MTGJSON instead of api.magicthegathering.io.
How the data is served
MTGJSON publishes whole files rather than a query API, so the client keeps a local copy of MTGJSON's AllPrintings SQLite build. On first start it streams AllPrintings.sqlite.gz (~250 MB) and inflates it to disk (~700 MB); after that it checks Meta.json daily and installs a new build only when MTGJSON has published one. Card, set and booster lookups run against that file. Decks, card types, keywords and build metadata come straight from the API.
Requires the pdo_sqlite and zlib extensions, and about 1.4 GB of free disk space.
New
- Card search on every MTGJSON card field, keeping the old
|(or) /,(and) syntax and the old parameter names (cmc,set,flavor,multiverseid,imageUrl, …) as aliases. Exact name matches and regular printings rank first. - Foreign-name search (
language+name), format legality (gameFormat+legality), any identifier (scryfallId,mtgArenaId, …). SetRepository::generateBooster()works again, opening packs from MTGJSON's booster configurations;getBoosterTypes()lists them.DeckRepository($mtg->decks): search the deck list, fetch a deck with its cards.MTG::getKeywords(),getEnumValues(),getMeta(),getCardTypes().- Card images from Scryfall (
$card->image_url); identifiers, purchase URLs and leadership skills as parts. - The bot answers a failed search instead of leaving
/card_searchthinking.
Fixed
- DiscordPHP's bootstrap client part could reclaim the client after startup, intermittently turning
$mtg->cardsand$mtg->setsinto null.
Breaking changes
- Card fields use MTGJSON's names (
manaValue,setCode,flavorText,uuid, …);ForeignNameis nowForeignData; theCardAttributestrait is gone. - Sets are keyed by
code. getFormats()returns MTGJSON's format keys (commander,paupercommander, …).- The
mtg_api_keyoption is gone;MTGtakes anmtgjsonoption (database,refresh_interval,preload). .env.exampleis nowenv.example;MTGJSON_DATABASEmoves the build out ofvar/mtgjson/.
Full Changelog: v0.10.2...v1.0.0
Card prices (daily)
Today's card prices for DiscordPHP-MTG, rebuilt daily from MTGJSON's AllPricesToday by the prices workflow. prices.sqlite.gz is the build the bot downloads; prices.json holds its MTGJSON date and version. Prices come from MTGJSON's partners (TCGplayer, Card Kingdom, Cardmarket, Mana Pool, Cardhoarder).