DiscordPHP Documentation

Discord

Namespaces

Builders
CommandClient
Exceptions
Factory
Helpers
Parts
Repository
Voice
WebSockets

Interfaces, Classes, Traits and Enums

Discord
The Discord client class.
DiscordCommandClient
Provides an easy way to have triggerable message based commands.

Table of Contents

COLORTABLE  = ['indianred' => 0xcd5c5c, 'lightcoral' => 0xf08080, 'salmon' => 0xfa8072, 'darksalmon' => 0xe9967a, 'lightsalmon' => 0xffa07a, 'crimson' => 0xdc143c, 'red' => 0xff0000, 'firebrick' => 0xb22222, 'darkred' => 0x8b0000, 'pink' => 0xffc0cb, 'lightpink' => 0xffb6c1, 'hotpink' => 0xff69b4, 'deeppink' => 0xff1493, 'mediumvioletred' => 0xc71585, 'palevioletred' => 0xdb7093, 'lightsalmon' => 0xffa07a, 'coral' => 0xff7f50, 'tomato' => 0xff6347, 'orangered' => 0xff4500, 'darkorange' => 0xff8c00, 'orange' => 0xffa500, 'gold' => 0xffd700, 'yellow' => 0xffff00, 'lightyellow' => 0xffffe0, 'lemonchiffon' => 0xfffacd, 'lightgoldenrodyellow' => 0xfafad2, 'papayawhip' => 0xffefd5, 'moccasin' => 0xffe4b5, 'peachpuff' => 0xffdab9, 'palegoldenrod' => 0xeee8aa, 'khaki' => 0xf0e68c, 'darkkhaki' => 0xbdb76b, 'lavender' => 0xe6e6fa, 'thistle' => 0xd8bfd8, 'plum' => 0xdda0dd, 'violet' => 0xee82ee, 'orchid' => 0xda70d6, 'fuchsia' => 0xff00ff, 'magenta' => 0xff00ff, 'mediumorchid' => 0xba55d3, 'mediumpurple' => 0x9370db, 'rebeccapurple' => 0x663399, 'blueviolet' => 0x8a2be2, 'darkviolet' => 0x9400d3, 'darkorchid' => 0x9932cc, 'darkmagenta' => 0x8b008b, 'purple' => 0x800080, 'indigo' => 0x4b0082, 'slateblue' => 0x6a5acd, 'darkslateblue' => 0x483d8b, 'mediumslateblue' => 0x7b68ee, 'greenyellow' => 0xadff2f, 'chartreuse' => 0x7fff00, 'lawngreen' => 0x7cfc00, 'lime' => 0xff00, 'limegreen' => 0x32cd32, 'palegreen' => 0x98fb98, 'lightgreen' => 0x90ee90, 'mediumspringgreen' => 0xfa9a, 'springgreen' => 0xff7f, 'mediumseagreen' => 0x3cb371, 'seagreen' => 0x2e8b57, 'forestgreen' => 0x228b22, 'green' => 0x8000, 'darkgreen' => 0x6400, 'yellowgreen' => 0x9acd32, 'olivedrab' => 0x6b8e23, 'olive' => 0x808000, 'darkolivegreen' => 0x556b2f, 'mediumaquamarine' => 0x66cdaa, 'darkseagreen' => 0x8fbc8b, 'lightseagreen' => 0x20b2aa, 'darkcyan' => 0x8b8b, 'teal' => 0x8080, 'aqua' => 0xffff, 'cyan' => 0xffff, 'lightcyan' => 0xe0ffff, 'paleturquoise' => 0xafeeee, 'aquamarine' => 0x7fffd4, 'turquoise' => 0x40e0d0, 'mediumturquoise' => 0x48d1cc, 'darkturquoise' => 0xced1, 'cadetblue' => 0x5f9ea0, 'steelblue' => 0x4682b4, 'lightsteelblue' => 0xb0c4de, 'powderblue' => 0xb0e0e6, 'lightblue' => 0xadd8e6, 'skyblue' => 0x87ceeb, 'lightskyblue' => 0x87cefa, 'deepskyblue' => 0xbfff, 'dodgerblue' => 0x1e90ff, 'cornflowerblue' => 0x6495ed, 'mediumslateblue' => 0x7b68ee, 'royalblue' => 0x4169e1, 'blue' => 0xff, 'mediumblue' => 0xcd, 'darkblue' => 0x8b, 'navy' => 0x80, 'midnightblue' => 0x191970, 'cornsilk' => 0xfff8dc, 'blanchedalmond' => 0xffebcd, 'bisque' => 0xffe4c4, 'navajowhite' => 0xffdead, 'wheat' => 0xf5deb3, 'burlywood' => 0xdeb887, 'tan' => 0xd2b48c, 'rosybrown' => 0xbc8f8f, 'sandybrown' => 0xf4a460, 'goldenrod' => 0xdaa520, 'darkgoldenrod' => 0xb8860b, 'peru' => 0xcd853f, 'chocolate' => 0xd2691e, 'saddlebrown' => 0x8b4513, 'sienna' => 0xa0522d, 'brown' => 0xa52a2a, 'maroon' => 0x800000, 'white' => 0xffffff, 'snow' => 0xfffafa, 'honeydew' => 0xf0fff0, 'mintcream' => 0xf5fffa, 'azure' => 0xf0ffff, 'aliceblue' => 0xf0f8ff, 'ghostwhite' => 0xf8f8ff, 'whitesmoke' => 0xf5f5f5, 'seashell' => 0xfff5ee, 'beige' => 0xf5f5dc, 'oldlace' => 0xfdf5e6, 'floralwhite' => 0xfffaf0, 'ivory' => 0xfffff0, 'antiquewhite' => 0xfaebd7, 'linen' => 0xfaf0e6, 'lavenderblush' => 0xfff0f5, 'mistyrose' => 0xffe4e1, 'gainsboro' => 0xdcdcdc, 'lightgray' => 0xd3d3d3, 'silver' => 0xc0c0c0, 'darkgray' => 0xa9a9a9, 'gray' => 0x808080, 'dimgray' => 0x696969, 'lightslategray' => 0x778899, 'slategray' => 0x708090, 'darkslategray' => 0x2f4f4f, 'black' => 0x0]
The HTML Color Table.
mentioned()  : bool
Checks to see if a part has been mentioned.
getColor()  : int
Get int value for color.
contains()  : bool
Checks if a string contains an array of phrases.
studly()  : string
Converts a string to studlyCase.
poly_strlen()  : int
Polyfill to check if mbstring is installed.
imageToBase64()  : string
Converts a file to base64 representation.
getSnowflakeTimestamp()  : float
Takes a snowflake and calculates the time that the snowflake was generated.
escapeMarkdown()  : string
Escape various Discord formatting and markdown into a plain text: _Italics_, **Bold**, __Underline__, ~~Strikethrough~~, ||spoiler|| `Code`, ```Code block```, > Quotes, >>> Block quotes #Channel @User A backslash will be added before the each formatting symbol.
deferFind()  : Promise
Run a deferred search in array.
nowait()  : mixed
Attempts to return a resolved value from a synchronous promise.

Constants

COLORTABLE

The HTML Color Table.

public array<string|int, mixed> COLORTABLE = ['indianred' => 0xcd5c5c, 'lightcoral' => 0xf08080, 'salmon' => 0xfa8072, 'darksalmon' => 0xe9967a, 'lightsalmon' => 0xffa07a, 'crimson' => 0xdc143c, 'red' => 0xff0000, 'firebrick' => 0xb22222, 'darkred' => 0x8b0000, 'pink' => 0xffc0cb, 'lightpink' => 0xffb6c1, 'hotpink' => 0xff69b4, 'deeppink' => 0xff1493, 'mediumvioletred' => 0xc71585, 'palevioletred' => 0xdb7093, 'lightsalmon' => 0xffa07a, 'coral' => 0xff7f50, 'tomato' => 0xff6347, 'orangered' => 0xff4500, 'darkorange' => 0xff8c00, 'orange' => 0xffa500, 'gold' => 0xffd700, 'yellow' => 0xffff00, 'lightyellow' => 0xffffe0, 'lemonchiffon' => 0xfffacd, 'lightgoldenrodyellow' => 0xfafad2, 'papayawhip' => 0xffefd5, 'moccasin' => 0xffe4b5, 'peachpuff' => 0xffdab9, 'palegoldenrod' => 0xeee8aa, 'khaki' => 0xf0e68c, 'darkkhaki' => 0xbdb76b, 'lavender' => 0xe6e6fa, 'thistle' => 0xd8bfd8, 'plum' => 0xdda0dd, 'violet' => 0xee82ee, 'orchid' => 0xda70d6, 'fuchsia' => 0xff00ff, 'magenta' => 0xff00ff, 'mediumorchid' => 0xba55d3, 'mediumpurple' => 0x9370db, 'rebeccapurple' => 0x663399, 'blueviolet' => 0x8a2be2, 'darkviolet' => 0x9400d3, 'darkorchid' => 0x9932cc, 'darkmagenta' => 0x8b008b, 'purple' => 0x800080, 'indigo' => 0x4b0082, 'slateblue' => 0x6a5acd, 'darkslateblue' => 0x483d8b, 'mediumslateblue' => 0x7b68ee, 'greenyellow' => 0xadff2f, 'chartreuse' => 0x7fff00, 'lawngreen' => 0x7cfc00, 'lime' => 0xff00, 'limegreen' => 0x32cd32, 'palegreen' => 0x98fb98, 'lightgreen' => 0x90ee90, 'mediumspringgreen' => 0xfa9a, 'springgreen' => 0xff7f, 'mediumseagreen' => 0x3cb371, 'seagreen' => 0x2e8b57, 'forestgreen' => 0x228b22, 'green' => 0x8000, 'darkgreen' => 0x6400, 'yellowgreen' => 0x9acd32, 'olivedrab' => 0x6b8e23, 'olive' => 0x808000, 'darkolivegreen' => 0x556b2f, 'mediumaquamarine' => 0x66cdaa, 'darkseagreen' => 0x8fbc8b, 'lightseagreen' => 0x20b2aa, 'darkcyan' => 0x8b8b, 'teal' => 0x8080, 'aqua' => 0xffff, 'cyan' => 0xffff, 'lightcyan' => 0xe0ffff, 'paleturquoise' => 0xafeeee, 'aquamarine' => 0x7fffd4, 'turquoise' => 0x40e0d0, 'mediumturquoise' => 0x48d1cc, 'darkturquoise' => 0xced1, 'cadetblue' => 0x5f9ea0, 'steelblue' => 0x4682b4, 'lightsteelblue' => 0xb0c4de, 'powderblue' => 0xb0e0e6, 'lightblue' => 0xadd8e6, 'skyblue' => 0x87ceeb, 'lightskyblue' => 0x87cefa, 'deepskyblue' => 0xbfff, 'dodgerblue' => 0x1e90ff, 'cornflowerblue' => 0x6495ed, 'mediumslateblue' => 0x7b68ee, 'royalblue' => 0x4169e1, 'blue' => 0xff, 'mediumblue' => 0xcd, 'darkblue' => 0x8b, 'navy' => 0x80, 'midnightblue' => 0x191970, 'cornsilk' => 0xfff8dc, 'blanchedalmond' => 0xffebcd, 'bisque' => 0xffe4c4, 'navajowhite' => 0xffdead, 'wheat' => 0xf5deb3, 'burlywood' => 0xdeb887, 'tan' => 0xd2b48c, 'rosybrown' => 0xbc8f8f, 'sandybrown' => 0xf4a460, 'goldenrod' => 0xdaa520, 'darkgoldenrod' => 0xb8860b, 'peru' => 0xcd853f, 'chocolate' => 0xd2691e, 'saddlebrown' => 0x8b4513, 'sienna' => 0xa0522d, 'brown' => 0xa52a2a, 'maroon' => 0x800000, 'white' => 0xffffff, 'snow' => 0xfffafa, 'honeydew' => 0xf0fff0, 'mintcream' => 0xf5fffa, 'azure' => 0xf0ffff, 'aliceblue' => 0xf0f8ff, 'ghostwhite' => 0xf8f8ff, 'whitesmoke' => 0xf5f5f5, 'seashell' => 0xfff5ee, 'beige' => 0xf5f5dc, 'oldlace' => 0xfdf5e6, 'floralwhite' => 0xfffaf0, 'ivory' => 0xfffff0, 'antiquewhite' => 0xfaebd7, 'linen' => 0xfaf0e6, 'lavenderblush' => 0xfff0f5, 'mistyrose' => 0xffe4e1, 'gainsboro' => 0xdcdcdc, 'lightgray' => 0xd3d3d3, 'silver' => 0xc0c0c0, 'darkgray' => 0xa9a9a9, 'gray' => 0x808080, 'dimgray' => 0x696969, 'lightslategray' => 0x778899, 'slategray' => 0x708090, 'darkslategray' => 0x2f4f4f, 'black' => 0x0]

HTML Color Table.

Tags
since
5.0.12

Functions

mentioned()

Checks to see if a part has been mentioned.

mentioned(Part|string $part, Message $message) : bool
Parameters
$part : Part|string

The part or mention to look for.

$message : Message

The message to check.

Tags
since
4.0.0
Return values
bool

Whether the part was mentioned.

getColor()

Get int value for color.

getColor(int|string $color) : int
Parameters
$color : int|string

The color's int, hexcode or htmlname.

Tags
since
5.0.12
Return values
int

color

contains()

Checks if a string contains an array of phrases.

contains(string $string, array<string|int, mixed> $matches) : bool
Parameters
$string : string

The string to check.

$matches : array<string|int, mixed>

Array containing one or more phrases to match.

Tags
since
5.0.12
Return values
bool

studly()

Converts a string to studlyCase.

studly(string $string) : string
Parameters
$string : string

The string to convert.

Tags
since
5.0.12
Return values
string

poly_strlen()

Polyfill to check if mbstring is installed.

poly_strlen(string $str) : int
Parameters
$str : string
Tags
since
5.0.12
Return values
int

imageToBase64()

Converts a file to base64 representation.

imageToBase64(string $filepath) : string
Parameters
$filepath : string
Tags
since
5.1.0
Return values
string

getSnowflakeTimestamp()

Takes a snowflake and calculates the time that the snowflake was generated.

getSnowflakeTimestamp(string|float $snowflake) : float
Parameters
$snowflake : string|float
Tags
since
5.1.1
Return values
float

escapeMarkdown()

Escape various Discord formatting and markdown into a plain text: _Italics_, **Bold**, __Underline__, ~~Strikethrough~~, ||spoiler|| `Code`, ```Code block```, > Quotes, >>> Block quotes #Channel @User A backslash will be added before the each formatting symbol.

escapeMarkdown(string $text) : string
Parameters
$text : string
Tags
since
6.0.2
Return values
string

the escaped string unformatted as plain text

deferFind()

Run a deferred search in array.

deferFind(array<string|int, mixed>|object $array, callable $callback[, LoopInterface|null $loop = null ]) : Promise
Parameters
$array : array<string|int, mixed>|object

Traversable, use $collection->getIterator() if searching in Collection

$callback : callable

The filter function to run

$loop : LoopInterface|null = null

Loop interface, use $discord->getLoop()

Tags
since
10.0.0

Handle $canceller internally, use cancel() from the returned promise.

since
7.1.0
Return values
Promise

nowait()

Attempts to return a resolved value from a synchronous promise.

nowait(PromiseInterface $promiseInterface) : mixed

Like await() but only for resolvable blocking promise without touching the loop.

Parameters
$promiseInterface : PromiseInterface

The synchronous promise.

Tags
see
await()

for asynchronous promise.

since
10.0.0
Return values
mixed

null if failed to return.

Search results