Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 1.26 KB

01_Basics.md

File metadata and controls

57 lines (45 loc) · 1.26 KB

Basics

API 101

  • All Setters are developed fluent so you can chain them: $webhook->setXY()->setYZ()->setEtc()

Webhook Configuration

After creating an instance of the webhook you're able to configure the following properties of the Bot:

  • Username
  • Avatar
Example
use DiscordWebhook\Webhook;

$wh = new Webhook(['https://my.webhook/url']);
$wh
    ->setUsername('My awesome BOT 💥')
    ->setAvatar('https://url.to/the_avatar.jpg');

Simple Text message

It's no rocket sience, just that simple:

use DiscordWebhook\Webhook;

$wh = new Webhook(['https://my.webhook/url']);
$wh
    ->setMessage('Test-message')
    ->send();

Text-To-Speech messages

If you want to send Text-To-Speech (TTS) messages just set the TTS to true

use DiscordWebhook\Webhook;

$wh = new Webhook(['https://my.webhook/url']);
$wh->setTts(true);

Multiple destinations

The constructor accepts an array. There you can pass multiple webhooks which are all executed. This is useful when you want to send the same information to multiple Discord servers.

use DiscordWebhook\Webhook;

$wh = new Webhook([
    'https://my.webhook/url',
    'https://another.webhook/url/v2',
    '...'
]);

$wh
    ->setMessage('Test-message')
    ->send();