From 19107b153e9e3a5e4a758b9db6a867c031467320 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 26 May 2023 00:04:16 +0200 Subject: Automated the extraction and delivery loop for a ship --- lib/ships.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/ships.js') diff --git a/lib/ships.js b/lib/ships.js index 9a57c12..6eefd87 100644 --- a/lib/ships.js +++ b/lib/ships.js @@ -5,7 +5,7 @@ export async function extract(ctx) { if (response.error !== undefined) { switch(response.error.code) { case 4000: // ship is on cooldown - await api.sleep(response.error.data.remainingSeconds * 1000); + await api.sleep(response.error.data.cooldown.remainingSeconds * 1000); return extract(ctx); case 4228: // ship is full return null; @@ -31,7 +31,9 @@ export async function dock(ctx) { } export async function navigate(ctx) { - return await api.send({endpoint: `/my/ships/${ctx.ship}/navigate`, method: 'POST', payload: { waypointSymbol: ctx.waypoint }}); + const response = await api.send({endpoint: `/my/ships/${ctx.ship}/navigate`, method: 'POST', payload: { waypointSymbol: ctx.waypoint }}); + const delay = new Date(response.data.nav.route.arrival) - new Date(); + await api.sleep(delay); } export async function orbit(ctx) { -- cgit v1.2.3