Easily create an object for discord embed.
Major Released: 2/8/23
Download the DiscordEmbed.php file and then require it to your project and you're ready to go!
require "DiscordEmbed.php";
Create new instance every time you create a new embed.
$embed = (new DiscordEmbed)
->setTitle("Cool title")
->setDescription("Cool description");
setTitle(string $title, ?string $url);
prependTitle(string $title);
appendTitle(string $title);
setUrl(string $url);
setDescription(string $description);
prependDescription(string $description);
appendDescription(string $description);
$color
can be a hex, decimal, or rgb (comma separated).
setColor(int $color);
setColor(string $color);
setRandomColor();
setTimestamp(?string $ts = date('c'));
# Associative array
$author = [
"name" => string,
"url" => ?string,
"icon_url" => ?string,
"proxy_icon_url" => ?string,
];
setAuthor(string $name, ?string $url, ?string $iconUrl, ?string $proxyIconUrl);
setAuthor(associative array $author);
# Associative array
$footer = [
"text" => string,
"icon_url" => string,
"proxy_icon_url" => ?string,
];
setFooter(string $text, ?string $iconUrl, ?string $proxyIconUrl);
setFooter(associative array $footer);
# Associative array
$image = [
"url" => string,
"proxy_url" => ?string,
"height" => ?int,
"width" => ?int,
];
setImage(string $url, ?string $proxyUrl, ?int $height, ?int $width);
setImage(associative array $image);
$thumbnail = [
# Associative array
"url" => string,
"proxy_url" => ?string,
"height" => ?int,
"width" => ?int,
];
setThumbnail(string $url, ?string $proxyUrl, ?int $height, ?int $width);
setThumbnail(associative array $thumbnail);
# Associative array
$field = [
"name" => string,
"value" => ?string,
"inline" => ?bool,
];
# Indexed array
$field = [
string $name,
?string $value,
?bool $inline,
];
addField(associative array $field);
addField(string $name, ?string $value, ?bool $inline);
addFields(associative|indexed array ...$fields);
toArray(): array;
toJSON(): string;