UNPKG

pterowrap

Version:

A node.js wrapper for Pterodactyl API

51 lines (50 loc) 1.94 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Schedule_1 = __importDefault(require("../../../structures/client/server/Schedule")); class ScheduleManager { constructor(client, _parentServer) { this.client = client; this._parentServer = _parentServer; } list(options = {}) { return new Promise(async (resolve, reject) => { try { const list = await this.client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules`, parameters: options }); const r = []; for (let i = 0; i < list.data.length; i++) { r.push(new Schedule_1.default(this.client, list.data[i], this._parentServer)); } resolve(r); } catch (e) { reject(e); } }); } get(id) { return new Promise(async (resolve, reject) => { try { const data = await this.client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules/${id}` }); resolve(new Schedule_1.default(this.client, data, this._parentServer)); } catch (e) { reject(e); } }); } create(params) { return new Promise(async (resolve, reject) => { try { const data = await this.client.call({ endpoint: `servers/${this._parentServer.identifier}/schedules`, method: "POST", body: params }); resolve(new Schedule_1.default(this.client, data, this._parentServer)); } catch (e) { reject(e); } }); } } exports.default = ScheduleManager;