MTG
extends MessageCommandClient
in package
uses
HelperTrait
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.
Tags
Table of Contents
Constants
- GITHUB : string = 'https://github.com/discord-php/DiscordPHP-MTG'
Properties
- $cards : CardRepository
- $sets : SetRepository
- $client : Client
- The extended Client class.
- $mtg_http : Http
- The extended HTTP client.
- $stats : Stats
Methods
- __construct() : mixed
- __encapsulatedSymbolsToEmojis() : string|null
- Converts encapsulated symbol placeholders within a string to their corresponding emoji representations.
- __get() : mixed
- Handles dynamic get calls to the client.
- colorIdentityToInteger() : int|null
- Converts a color identity string to its corresponding integer representation.
- createBuilder() : MessageBuilder
- Creates a new instance of MessageBuilder.
- encapsulated_emoji_str_replace() : string
- Replaces a placeholder in the given string with the string representation of an Emoji object.
- encapsulatedSymbolsToEmojis() : string
- Replaces every `{X}` mana/symbol token in a string with the matching application emoji (stored under the name `X_`, e.g. `{U}` → emoji `U_`).
- getFormats() : PromiseInterface<string|int, array<string|int, string>>
- Fetches the API's list of all game formats (e.g. `Standard`, `Commander`).
- getMtgHttpClient() : Http
- Gets the MTG HTTP client.
- getSubtypes() : PromiseInterface<string|int, array<string|int, string>>
- Fetches the API's list of all card subtypes (e.g. `Elf`, `Equipment`).
- getSupertypes() : PromiseInterface<string|int, array<string|int, string>>
- Fetches the API's list of all card supertypes (e.g. `Legendary`, `Snow`).
- getTypes() : PromiseInterface<string|int, array<string|int, string>>
- Fetches the API's list of all card types (e.g. `Creature`, `Instant`).
Constants
GITHUB
public
string
GITHUB
= 'https://github.com/discord-php/DiscordPHP-MTG'
Properties
$cards
public
CardRepository
$cards
$sets
public
SetRepository
$sets
$client
The extended Client class.
protected
Client
$client
Extended Discord client.
$mtg_http
The extended HTTP client.
protected
Http
$mtg_http
Extended Discord HTTP client.
$stats
protected
Stats
$stats
Methods
__construct()
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
__encapsulatedSymbolsToEmojis()
Converts encapsulated symbol placeholders within a string to their corresponding emoji representations.
public
__encapsulatedSymbolsToEmojis(string $subject, string $search) : string|null
Parameters
- $subject : string
-
The input string containing symbol placeholders to be replaced.
- $search : string
-
The symbol name to search for and replace with its emoji.
Tags
Return values
string|null —The string with symbols replaced by emojis, or null if no emoji is found.
__get()
Handles dynamic get calls to the client.
public
__get(string $name) : mixed
Parameters
- $name : string
-
Variable name.
colorIdentityToInteger()
Converts a color identity string to its corresponding integer representation.
public
static colorIdentityToInteger(string|null $identity) : int|null
Parameters
- $identity : string|null
-
The color identity string to convert.
Tags
Return values
int|nullcreateBuilder()
Creates a new instance of MessageBuilder.
public
static createBuilder([bool $prevent_mentions = false ]) : MessageBuilder
Optionally prevents mentions in the message by setting allowed mentions to none.
Parameters
- $prevent_mentions : bool = false
-
Whether to prevent mentions in the message. Defaults to false.
Tags
Return values
MessageBuilderencapsulated_emoji_str_replace()
Replaces a placeholder in the given string with the string representation of an Emoji object.
public
static encapsulated_emoji_str_replace(string $search, Emoji $emoji, string $subject) : string
Parameters
- $search : string
- $emoji : Emoji
-
The Emoji object whose string representation will replace the placeholder.
- $subject : string
Tags
Return values
string —The resulting string with the placeholder replaced by the emoji.
encapsulatedSymbolsToEmojis()
Replaces every `{X}` mana/symbol token in a string with the matching application emoji (stored under the name `X_`, e.g. `{U}` → emoji `U_`).
public
encapsulatedSymbolsToEmojis(string $subject) : string
Tokens with no matching emoji are left as-is.
Parameters
- $subject : string
-
Card text containing
{...}symbol tokens.
Tags
Return values
string —The text with known symbols replaced by emojis.
getFormats()
Fetches the API's list of all game formats (e.g. `Standard`, `Commander`).
public
getFormats() : PromiseInterface<string|int, array<string|int, string>>
Tags
Return values
PromiseInterface<string|int, array<string|int, string>>getMtgHttpClient()
Gets the MTG HTTP client.
public
getMtgHttpClient() : Http
Return values
HttpgetSubtypes()
Fetches the API's list of all card subtypes (e.g. `Elf`, `Equipment`).
public
getSubtypes() : PromiseInterface<string|int, array<string|int, string>>
Tags
Return values
PromiseInterface<string|int, array<string|int, string>>getSupertypes()
Fetches the API's list of all card supertypes (e.g. `Legendary`, `Snow`).
public
getSupertypes() : PromiseInterface<string|int, array<string|int, string>>
Tags
Return values
PromiseInterface<string|int, array<string|int, string>>getTypes()
Fetches the API's list of all card types (e.g. `Creature`, `Instant`).
public
getTypes() : PromiseInterface<string|int, array<string|int, string>>