Skip to content

Commit 5c23b8d

Browse files
committed
Update DiscordChannel.php
1 parent 693aa61 commit 5c23b8d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/DiscordChannel.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Client\PendingRequest;
66
use Illuminate\Http\Client\RequestException;
7+
use Illuminate\Http\Client\Response;
78
use Illuminate\Notifications\Notification;
89
use Illuminate\Support\Facades\Http;
910

@@ -12,15 +13,15 @@ class DiscordChannel
1213
/**
1314
* @throws RequestException
1415
*/
15-
public function send(mixed $notifiable, Notification $notification): void
16+
public function send(mixed $notifiable, Notification $notification): ?Response
1617
{
1718
/**
1819
* @var DiscordMessage $message
1920
*/
2021
$message = $notification->toDiscordWebhook($notifiable);
2122

2223
if (! $message->isValid()) {
23-
return;
24+
return null;
2425
}
2526

2627
/**
@@ -29,22 +30,22 @@ public function send(mixed $notifiable, Notification $notification): void
2930
$webhook_url = $notifiable->routeNotificationFor('discord-webhook');
3031

3132
if (empty($webhook_url)) {
32-
return;
33+
return null;
3334
}
3435

35-
Http::attach(
36+
return Http::attach(
3637
name: 'payload_json',
3738
contents: $message->toJson(),
38-
headers: ['Content-Type' => 'application/json']
39+
headers: ['Content-Type' => 'application/json'],
3940
)->when(filled($message->getAttachments()), function (PendingRequest $client) use ($message) {
4041
foreach ($message->getAttachments() as $id => $attach) {
4142
$client->attach(
4243
name: "files[$id]",
4344
contents: $attach->content,
4445
filename: $attach->filename,
45-
headers: ['Content-Type' => $attach->filetype]
46+
headers: ['Content-Type' => $attach->filetype],
4647
);
4748
}
48-
})->post($webhook_url)->throw();
49+
})->post($webhook_url);
4950
}
5051
}

0 commit comments

Comments
 (0)