Client()

A client for interacting with the ReplCraft server

new Client()

Fires:
  • event:outOfFuel when a request encounters an out-of-fuel error
  • event:transact when a player uses the /transact command inside the structure
  • event:contextOpened when a new structure context is opened
  • event:contextOpened when a structure context is closed

Methods

disconnect()

Disconnects the client

async login(token) → {Promise.<{scope: String, context: ?StructureContext}>}

Logs the client in and returns a promise that resolves once authenticated.
Parameters:
Name Type Description
token String your api token
Fires:
Throws:
Returns:
Promise.<{scope: String, context: ?StructureContext}>

async request(args, contextnullable) → {Promise.<Object>}

Makes a request to the server. You probably shouldn't use this directly.
Parameters:
Name Type Attributes Description
args Object the request to make
context StructureContext <nullable>
the context making this request
Throws:
Returns:
Promise.<Object>

retryOnFuelError(retry)

Enables or disables automatic retries when out of fuel. Note that requests will hang indefinitely until fuel is supplied. You can monitor fuel status by listening to the "outOfFuel" event
Parameters:
Name Type Default Description
retry boolean true if retries should be enabled or disabled