Skip to content

Commit 7ce05c7

Browse files
authored
silently fail when webhook is not reachable
1 parent 44612aa commit 7ce05c7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/DiscordHandler.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function write(array $record): void
5353
$log = [
5454
'embeds' => [
5555
[
56-
'title' => 'Log from ' . $this->name,
56+
'title' => 'Log entry - '.now()->format('d.m.Y H:i:s'),
5757
// Use CSS for the formatter, as it provides the most distinct colouring.
5858
'description' => "```css\n" . substr($content, 0, 2030). '```',
5959
'color' => 0xE74C3C,
@@ -64,11 +64,16 @@ protected function write(array $record): void
6464
// Tag a role if configured for it
6565
if($this->roleId) $log['content'] = "<@&" . $this->roleId . ">";
6666

67-
68-
// Send it to discord
69-
$this->guzzle->request('POST', $this->webhook, [
70-
RequestOptions::JSON => $log,
71-
]);
67+
if($this->webhook) {
68+
try {
69+
// Send it to discord
70+
$this->guzzle->request('POST', $this->webhook, [
71+
RequestOptions::JSON => $log,
72+
]);
73+
} catch (\Exception $e) {
74+
//silently fail
75+
}
76+
}
7277
}
7378
}
7479

0 commit comments

Comments
 (0)