DiscordPHP-MTG Documentation

Application

Table of Contents

Classes

Stats
Tracks bot runtime metrics — start time, last reconnect, message/event counters — and renders them as an {@see Embed} for a `!stats` style command.
Client
The DiscordPHP {@see \Discord\Parts\User\Client} extended so the MTG repositories ({@see CardRepository}, {@see SetRepository}) hang off the same client the rest of the bot uses. Held by {@see MTG} as `$client`.
Collection
Collection of items. Inspired by Laravel Collections. A local copy of DiscordPHP's `Collection` so MTG code has an `MTG\Helpers`-namespaced type; behaviour comes entirely from {@see CollectionTrait}.
Endpoint
The route table for the "Magic: The Gathering Developers" API — one constant per endpoint (`cards`, `sets`, `sets/:id/booster`, `types`, `formats`, …), with `:param` placeholders bound via {@see EndpointTrait}. Same mechanics as DiscordPHP's own `Endpoint`, pointed at `api.magicthegathering.io`.
Http
HTTP client for the "Magic: The Gathering Developers" REST API, built the same way DiscordPHP talks to `discord.com` (rate-limit buckets, driver, retry) but pointed at `api.magicthegathering.io`. The API is read-only and unauthenticated, so no token is required.
Request
A single queued HTTP request against the MTG API. Identical in behaviour to the DiscordPHP request it extends; it exists only so MTG transport code depends on an MTG-owned type.
MTG
The MTG client class — a DiscordPHP {@see MessageCommandClient} extended with an async HTTP client for the "Magic: The Gathering Developers" REST API and the card / set repositories that read it.
Card
Represents a Magic: The Gathering card (one object from the API's `cards` response); {@see CardAttributes} declares the raw API fields and this class adds the collections and Discord render helpers.
ForeignName
Foreign language names for the card, if this card in this set was printed in another language. Not available for all sets.
Legality
One entry from a {@see Card}'s `legalities` array — whether the card is `Legal` / `Banned` / `Restricted` in a given format. Not a standalone endpoint; it only appears inside the card response.
Ruling
One entry from a {@see Card}'s `rulings` array — an official clarification, with the date it was issued. Not a standalone endpoint; it only appears inside the card response.
Set
Represents a Magic: The Gathering set (one object from the API's `sets` response) — its code, name, release date, block and booster configuration.
AbstractRepository
Base class for the MTG read-only repositories: DiscordPHP's {@see DiscordAbstractRepository} behaviour (keyed, cached collection of Parts) backed by {@see \MTG\Http\Http} and MTG {@see \MTG\Http\Endpoint}s instead of the Discord API. Concrete repositories ({@see CardRepository}, {@see SetRepository}) declare their endpoint map and Part class.
CardRepository
Reads the API's `cards` endpoint — list/search with query filters and pagination, and fetch a single card by id — hydrating {@see Card} parts.
SetRepository
Reads the API's `sets` endpoint — list sets, fetch one by code, and generate a booster pack from a set — hydrating {@see Set} parts.

Traits

HelperTrait
Small presentation helpers shared by {@see MTG} and its command handlers for turning MTG API data into Discord output: a mention-safe {@see MessageBuilder} factory and emoji lookup helpers. Pure formatting — no API or model concerns live here.
CardAttributes
This query will return a maximum of 100 cards.
AbstractRepositoryTrait
Shared implementation for every MTG repository: DiscordPHP's `AbstractRepositoryTrait` ported so the collection is keyed and cached the same way, but backed by {@see \MTG\Http\Http} and MTG {@see \MTG\Http\Endpoint}s. Consumed by {@see AbstractRepository}.
On this page

Search results