Skip to content

Commit

Permalink
StructureWentHighPower.php
Browse files Browse the repository at this point in the history
squash

StructureWentHighPower.php

squash
StyleCI

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

StructureWentHighPower.php

Added information with structure name
  • Loading branch information
MattFalahe committed Oct 21, 2024
1 parent b88d423 commit f1ec9e2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Notifications/Structures/Discord/StructureWentHighPower.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Seat\Eveapi\Models\Character\CharacterNotification;
use Seat\Eveapi\Models\Sde\InvType;
use Seat\Eveapi\Models\Sde\MapDenormalize;
use Seat\Eveapi\Models\Universe\UniverseStructure;
use Seat\Notifications\Notifications\AbstractDiscordNotification;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbed;
use Seat\Notifications\Services\Discord\Messages\DiscordEmbedField;
Expand Down Expand Up @@ -74,12 +75,25 @@ public function populateMessage(DiscordMessage $message, $notifiable): void
});

$embed->field(function (DiscordEmbedField $field) {
$type = InvType::firstOrNew(
['typeID' => $this->notification->text['structureTypeID']],
['typeName' => trans('web::seat.unknown')]
);
// Find the structure by its ID from the notification data.
// If the structure ID exists in the notification, retrieve it from the UniverseStructure model.
$structure = UniverseStructure::find($this->notification->text['structureID']);

// Retrieve the structure's type information using the structureShowInfoData from the notification.
// The second index ([1]) contains the type ID which is used to look up the structure type from the InvType model.
$type = InvType::find($this->notification->text['structureShowInfoData'][1]);

// Initialize a default title for the structure field as 'Structure'.
$title = 'Structure';

// If a structure is found (i.e., it's not null), set the title to the name of the structure.
if (! is_null($structure)) {
$title = $structure->name;
}

$field->name('Structure')
// Set the field's name to the title (either 'Structure' or the structure's actual name).
// Set the field's value to a zKillboard link, formatted for Discord. This uses the structure's type ID and name.
$field->name($title)
->value($this->zKillBoardToDiscordLink('ship', $type->typeID, $type->typeName));
});
});
Expand Down

0 comments on commit f1ec9e2

Please sign in to comment.