This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPayload.php
70 lines (54 loc) · 1.46 KB
/
Payload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace Enlumop\DiscordWebhooks;
use Enlumop\DiscordWebhooks\Interface\Embed\GetEmbedInterface;
use Enlumop\DiscordWebhooks\Interface\Payload\PayloadInterface;
class Payload implements PayloadInterface
{
protected ?string $username = null;
protected ?string $avatarUrl = null;
protected ?string $message = null;
/**
* @var null|array<array<mixed>>
*/
protected ?array $embeds = null;
protected bool $tts = false;
public function setUsername(string $username): static
{
$this->username = $username;
return $this;
}
public function setAvatarUrl(string $avatarUrl): static
{
$this->avatarUrl = $avatarUrl;
return $this;
}
public function setMessage(string $message): static
{
$this->message = $message;
return $this;
}
public function addEmbed(GetEmbedInterface $embed): static
{
if (null === $this->embeds) {
$this->embeds = [];
}
$this->embeds[] = $embed->toArray();
return $this;
}
public function setTts(bool $tts): static
{
$this->tts = $tts;
return $this;
}
public function toArray(): array
{
return [
'username' => $this->username,
'avatar_url' => $this->avatarUrl,
'content' => $this->message,
'embeds' => $this->embeds,
'tts' => $this->tts,
];
}
}