File tree 1 file changed +14
-3
lines changed 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 10
10
class Webhook
11
11
{
12
12
private string $ url ;
13
+ private string $ proxy ;
13
14
14
15
public function __construct (string $ url )
15
16
{
16
17
$ this ->url = $ url ;
17
18
}
18
19
20
+ public function setProxy (?string $ proxy ): self
21
+ {
22
+ $ this ->proxy = $ proxy ;
23
+
24
+ return $ this ;
25
+ }
26
+
19
27
/**
20
28
* @throws DiscordInvalidResponseException
21
29
* @throws DiscordSerializeException
22
- * @throws JsonException
23
30
*/
24
31
public function send (Message $ message ): int
25
32
{
26
- $ sent = false ;
33
+ $ data = $ message -> toArray () ;
27
34
$ options = [
28
35
CURLOPT_CUSTOMREQUEST => 'POST ' ,
29
36
CURLOPT_RETURNTRANSFER => true ,
30
37
];
31
38
32
- $ data = $ message ->toArray ();
39
+ if (!empty ($ this ->proxy )) {
40
+ $ options [CURLOPT_PROXY ] = $ this ->proxy ;
41
+ }
33
42
34
43
try {
35
44
if (isset ($ data ['file ' ])) {
@@ -54,6 +63,8 @@ public function send(Message $message): int
54
63
$ ch = curl_init ($ this ->url );
55
64
curl_setopt_array ($ ch , $ options );
56
65
66
+ $ sent = false ;
67
+
57
68
while (!$ sent ) {
58
69
$ response = curl_exec ($ ch );
59
70
$ code = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
You can’t perform that action at this time.
0 commit comments