Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.54 KB

03_Embeds.md

File metadata and controls

53 lines (41 loc) · 1.54 KB

Embeds

DiscordWebhook\Embed is the base class for creating an embed. A message can contain up to 10 embeds.

Every embed can contain different components. For every component there is a class which can be used to construct the embed according to your thoughts.

Elements

All properties are private. Use their getters and setters to access them.

  • DiscordWebhook\Embed (base class)
    • DiscordWebhook\Embed\Author
    • DiscordWebhook\Embed\Field
    • DiscordWebhook\Embed\Footer
    • DiscordWebhook\Embed\Image
    • DiscordWebhook\Embed\Provider
    • DiscordWebhook\Embed\Thumbnail
    • DiscordWebhook\Embed\Video
  • DiscordWebhook\EmbedColor (base colour class; see example below)

Simple example

<?php
declare(strict_types=1);

$wh = new \DiscordWebhook\Webhook(['https://webhook.url']);
$embed = new \DiscordWebhook\Embed();

$embed
    ->setTitle('My embed')
    ->setTimestamp(new DateTime('now'));

$wh
    ->setUsername('My bot')
    ->addEmbed($embed)
    ->send();

Result:
images/embed.png

Colouring your Embed

The DiscordWebhook\EmbedColor enum brings a palette of predefined colours which you can use, to colorize your embeds:

$embed = new \DiscordWebhook\Embed();

// Have a look at the class for a full list of available colours
$embed->setColor(\DiscordWebhook\EmbedColor::DARK_RED);

The colour used above will look like this:
images/colorized-embed.png