UNPKG

pterowrap

Version:

A node.js wrapper for Pterodactyl API

49 lines (48 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Task { constructor(_client, data, _parentServer, _parentSchedule) { this._client = _client; this._parentServer = _parentServer; this._parentSchedule = _parentSchedule; const attributes = data.attributes; this.id = attributes.id; this.sequence_id = attributes.sequence_id; this.action = attributes.action; this.payload = attributes.payload; this.time_offset = attributes.time_offset; this.is_queued = attributes.is_queued; this.created_at = attributes.created_at; this.updated_at = attributes.updated_at; this.raw = attributes; } update(params) { return new Promise(async (resolve, reject) => { try { const data = await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules/${this._parentSchedule.id}/tasks/${this.id}`, method: "POST", body: params, }); resolve(new Task(this._client, data, this._parentServer, this._parentSchedule)); } catch (e) { reject(e); } }); } delete() { return new Promise(async (resolve, reject) => { try { resolve(await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules/${this._parentSchedule.id}/tasks/${this.id}`, method: "DELETE", })); } catch (e) { reject(e); } }); } } exports.default = Task;