From 0c82ec7e856b06d04253ce5d4d1605673d54890b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Palm?= Date: Sat, 27 Jul 2024 19:06:27 +0200 Subject: [PATCH] fix: Fixed StructureUnderAttack if missing Alliance --- .../Discord/StructureUnderAttack.php | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Notifications/Structures/Discord/StructureUnderAttack.php b/src/Notifications/Structures/Discord/StructureUnderAttack.php index 43ef970..d7a73ad 100644 --- a/src/Notifications/Structures/Discord/StructureUnderAttack.php +++ b/src/Notifications/Structures/Discord/StructureUnderAttack.php @@ -66,14 +66,12 @@ public function populateMessage(DiscordMessage $message, $notifiable): void $this->notification->text['corpName'] ) ); - }) - ->field(function (DiscordEmbedField $field) { - if (! array_key_exists('allianceID', $this->notification->text) || is_null( - $this->notification->text['allianceID'] - )) { - return; - } + }); + if (array_key_exists('aggressorAllianceID', $this->notification->text) && ! is_null( + $this->notification->text['aggressorAllianceID'] + )) { + $embed->field(function (DiscordEmbedField $field) { $field->name('Alliance') ->value( $this->zKillBoardToDiscordLink( @@ -82,33 +80,35 @@ public function populateMessage(DiscordMessage $message, $notifiable): void $this->notification->text['allianceName'] ) ); - }) - ->field(function (DiscordEmbedField $field) { - $system = MapDenormalize::find($this->notification->text['solarsystemID']); + }); + } - $field->name('System') - ->value( - $this->zKillBoardToDiscordLink( - 'system', - $system->itemID, - $system->itemName . ' (' . number_format($system->security, 2) . ')' - ) - ); - }) - ->field(function (DiscordEmbedField $field) { - $structure = UniverseStructure::find($this->notification->text['structureID']); + $embed->field(function (DiscordEmbedField $field) { + $system = MapDenormalize::find($this->notification->text['solarsystemID']); - $type = InvType::find($this->notification->text['structureShowInfoData'][1]); + $field->name('System') + ->value( + $this->zKillBoardToDiscordLink( + 'system', + $system->itemID, + $system->itemName . ' (' . number_format($system->security, 2) . ')' + ) + ); + }) + ->field(function (DiscordEmbedField $field) { + $structure = UniverseStructure::find($this->notification->text['structureID']); - $title = 'Structure'; + $type = InvType::find($this->notification->text['structureShowInfoData'][1]); - if (! is_null($structure)) { - $title = $structure->name; - } + $title = 'Structure'; - $field->name($title) - ->value($type->typeName); - }); + if (! is_null($structure)) { + $title = $structure->name; + } + + $field->name($title) + ->value($type->typeName); + }); }) ->embed(function (DiscordEmbed $embed) { $embed->field(function (DiscordEmbedField $field) {