Skip to content

Commit 0e527ce

Browse files
authored
Added timeout setter (#5)
1 parent 404acc4 commit 0e527ce

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Webhook.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Webhook
1111
{
1212
private string $url;
1313
private ?string $proxy;
14+
private ?int $timeout;
1415

1516
public function __construct(string $url)
1617
{
@@ -24,6 +25,13 @@ public function setProxy(?string $proxy): self
2425
return $this;
2526
}
2627

28+
public function setTimeout(?int $timeout): self
29+
{
30+
$this->timeout = $timeout;
31+
32+
return $this;
33+
}
34+
2735
/**
2836
* @throws DiscordInvalidResponseException
2937
* @throws DiscordSerializeException
@@ -40,6 +48,10 @@ public function send(Message $message): int
4048
$options[CURLOPT_PROXY] = $this->proxy;
4149
}
4250

51+
if (!empty($this->timeout)) {
52+
$options[CURLOPT_TIMEOUT] = $this->timeout;
53+
}
54+
4355
try {
4456
if (isset($data['file'])) {
4557
$file = $data['file'];

0 commit comments

Comments
 (0)