From 98b8b73cb53555396d349974d75f4a151dcf5465 Mon Sep 17 00:00:00 2001 From: RVxLab Date: Sun, 14 Jul 2024 17:24:55 +1000 Subject: [PATCH] Only add the username property if it's not empty --- src/Notifications/Channels/Discord/DiscordMessage.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Notifications/Channels/Discord/DiscordMessage.php b/src/Notifications/Channels/Discord/DiscordMessage.php index 8854aef2..873655f7 100644 --- a/src/Notifications/Channels/Discord/DiscordMessage.php +++ b/src/Notifications/Channels/Discord/DiscordMessage.php @@ -110,8 +110,7 @@ public function fields(array $fields, bool $inline = true): self public function toArray(): array { - return [ - 'username' => $this->username ?? 'Laravel Backup', + $data = [ 'avatar_url' => $this->avatarUrl, 'embeds' => [ [ @@ -128,5 +127,11 @@ public function toArray(): array ], ], ]; + + if (!empty($this->username)) { + $data['username'] = $this->username; + } + + return $data; } }