1
0
Fork 0

Automated the extraction and delivery loop for a ship

This commit is contained in:
Julien Dessaux 2023-05-26 00:04:16 +02:00
parent b1157af9cd
commit 19107b153e
Signed by: adyxax
GPG key ID: F92E51B86E07177E
4 changed files with 94 additions and 112 deletions

View file

@ -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) {