File tree 2 files changed +18
-2
lines changed 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class Message implements ArrayableInterface
12
12
private ?string $ username = null ;
13
13
private bool $ tts = false ;
14
14
private ?string $ file = null ;
15
+ private ?string $ filename = null ;
15
16
16
17
private SplObjectStorage $ embeds ;
17
18
@@ -80,6 +81,18 @@ public function setFile(?string $file): self
80
81
return $ this ;
81
82
}
82
83
84
+ public function getFilename (): ?string
85
+ {
86
+ return $ this ->filename ;
87
+ }
88
+
89
+ public function setFilename (?string $ filename ): self
90
+ {
91
+ $ this ->filename = $ filename ;
92
+
93
+ return $ this ;
94
+ }
95
+
83
96
public function getEmbeds (): SplObjectStorage
84
97
{
85
98
return $ this ->embeds ;
@@ -133,6 +146,7 @@ public function toArray(): array
133
146
134
147
if ($ this ->file !== null ) {
135
148
$ data ['file ' ] = $ this ->file ;
149
+ $ data ['filename ' ] = $ this ->filename ?? basename ($ this ->file );
136
150
}
137
151
138
152
return $ data ;
Original file line number Diff line number Diff line change @@ -34,11 +34,13 @@ public function send(Message $message): int
34
34
try {
35
35
if (isset ($ data ['file ' ])) {
36
36
$ file = $ data ['file ' ];
37
- unset($ data ['file ' ]);
37
+ $ filename = $ data ['filename ' ];
38
+
39
+ unset($ data ['file ' ], $ data ['filename ' ]);
38
40
39
41
$ options [CURLOPT_HTTPHEADER ] = ['Content-type: multipart/form-data ' ];
40
42
$ options [CURLOPT_POSTFIELDS ] = [
41
- 'file ' => new CURLFile ($ file , '' , basename ( $ file ) ),
43
+ 'file ' => new CURLFile ($ file , '' , $ filename ),
42
44
'payload_json ' => json_encode ($ data , JSON_THROW_ON_ERROR ),
43
45
];
44
46
} else {
You can’t perform that action at this time.
0 commit comments