DiscordPHP-MTG Documentation

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
see
MessageCommandClient

The DiscordPHP client this extends

CardRepository
SetRepository
version
1.0.0

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

$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.

Methods

__construct()

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

Options passed straight to the DiscordPHP client, plus socket_options for the HTTP driver and an optional mtg_api_key (X-Api-Key, raises the MTG API rate limit). After the parent boots, the MTG HTTP client, the Client part and the Stats tracker are wired up.

__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
since
0.4.0
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
since
0.4.0
Return values
int|null

createBuilder()

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
since
0.1.0
Return values
MessageBuilder

encapsulated_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
since
0.4.0
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
since
0.4.0
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
link
https://docs.magicthegathering.io/#api_v1formats_list
Return values
PromiseInterface<string|int, array<string|int, string>>

getMtgHttpClient()

Gets the MTG HTTP client.

public getMtgHttpClient() : Http
Return values
Http

getTypes()

Fetches the API's list of all card types (e.g. `Creature`, `Instant`).

public getTypes() : PromiseInterface<string|int, array<string|int, string>>
Tags
link
https://docs.magicthegathering.io/#api_v1types_list
Return values
PromiseInterface<string|int, array<string|int, string>>
On this page

Search results