@@ -958,47 +958,50 @@ export class RustPlusInstance {
958958 const gInstance = gim . getGuildInstance ( this . guildId ) as GuildInstance ;
959959 const language = gInstance . generalSettings . language ;
960960
961+ if ( ! this . rpMapMarkers ) {
962+ return '\u200B' ;
963+ }
964+
961965 const strings : string [ ] = [ ] ;
962- if ( this . rpMapMarkers ) {
963- if ( this . rpMapMarkers . patrolHelicopters . length === 0 ) {
964- const dateWhenDestroyed = this . rpMapMarkers . datePatrolHelicopterDestroyed ;
965- const dateWhenLeftMap = this . rpMapMarkers . datePatrolHelicopterLeftMap ;
966- const destroyedLocation = this . rpMapMarkers . patrolHelicopterLastDestroyedLocation ;
967-
968- if ( dateWhenDestroyed !== null ) {
969- const timeSinceDestroyedSeconds = Math . floor ( dateWhenDestroyed . getTime ( ) / 1000 ) ;
970- const timeSinceDestroyedString = `<t:${ timeSinceDestroyedSeconds } :R>` ;
971- strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseDestroyedTimeAtPos' , {
972- time : timeSinceDestroyedString ,
973- location : destroyedLocation ?? lm . getIntl ( language , 'unknown' )
974- } ) ) ;
975- }
966+ if ( this . rpMapMarkers . patrolHelicopters . length === 0 ) {
967+ const dateDestroyed = this . rpMapMarkers . datePatrolHelicopterDestroyed ;
968+ const dateDespawned = this . rpMapMarkers . datePatrolHelicopterDespawned ;
969+ const destroyedLocation = this . rpMapMarkers . patrolHelicopterLastDestroyedLocation ;
970+
971+ if ( dateDestroyed ) {
972+ const unixTimestampDestroyed = Math . floor ( dateDestroyed . getTime ( ) / 1000 ) ;
973+ const timeDestroyed = Timer . getDiscordRelativeTime ( unixTimestampDestroyed ) ;
974+ strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseDestroyedTimeAtPos' , {
975+ time : timeDestroyed ,
976+ location : destroyedLocation ?? lm . getIntl ( language , 'unknown' )
977+ } ) ) ;
978+ }
976979
977- if ( dateWhenLeftMap !== null ) {
978- const timeSinceLeftMapSeconds = Math . floor ( dateWhenLeftMap . getTime ( ) / 1000 ) ;
979- const timeSinceLeftMapString = `<t: ${ timeSinceLeftMapSeconds } :R>` ;
980- strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLeftTime' , {
981- time : timeSinceLeftMapString
982- } ) ) ;
983- }
980+ if ( dateDespawned ) {
981+ const unixTimestampDespawned = Math . floor ( dateDespawned . getTime ( ) / 1000 ) ;
982+ const timeDespawned = Timer . getDiscordRelativeTime ( unixTimestampDespawned ) ;
983+ strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLeftTime' , {
984+ time : timeDespawned
985+ } ) ) ;
986+ }
984987
985- if ( strings . length === 0 ) {
986- strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseNotActive' ) ) ;
987- }
988+ if ( strings . length === 0 ) {
989+ strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseNotActive' ) ) ;
988990 }
991+ }
989992
990- for ( const patrolHelicopter of this . rpMapMarkers . patrolHelicopters ) {
991- const metaData = this . rpMapMarkers . patrolHelicopterMetaData [ patrolHelicopter . id ] ;
992- const pos = getPos ( patrolHelicopter . x , patrolHelicopter . y , this ) ;
993- const posString = ( pos !== null ) ? getPosString ( pos , this , true , false ) :
994- lm . getIntl ( language , 'unknown' ) ;
993+ for ( const patrolHelicopter of this . rpMapMarkers . patrolHelicopters ) {
994+ const metaData = this . rpMapMarkers . patrolHelicopterMetaData [ patrolHelicopter . id ] ;
995995
996- if ( metaData . isLeaving ) {
997- strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLeavingAtPos' , { pos : posString } ) ) ;
998- }
999- else {
1000- strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLocatedAtPos' , { pos : posString } ) ) ;
1001- }
996+ const pos = getPos ( patrolHelicopter . x , patrolHelicopter . y , this ) ;
997+ const posString = ( pos !== null ) ? getPosString ( pos , this , true , false ) :
998+ lm . getIntl ( language , 'unknown' ) ;
999+
1000+ if ( metaData . isLeaving ) {
1001+ strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLeavingAtPos' , { pos : posString } ) ) ;
1002+ }
1003+ else {
1004+ strings . push ( lm . getIntl ( language , 'infoChannelEmbedEventPhraseLocatedAtPos' , { pos : posString } ) ) ;
10021005 }
10031006 }
10041007
0 commit comments