pterowrap
Version:
A node.js wrapper for Pterodactyl API
43 lines (42 loc) • 1.53 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Variable_1 = __importDefault(require("../../../structures/client/server/Variable"));
class VariableManager {
constructor(client, _parentServer) {
this.client = client;
this._parentServer = _parentServer;
}
list() {
return new Promise(async (resolve, reject) => {
try {
const list = await this.client.call({ endpoint: `servers/${this._parentServer.identifier}/startup` });
const r = [];
for (let i = 0; i < list.data.length; i++) {
r.push(new Variable_1.default(this.client, list.data[i], this._parentServer));
}
resolve(r);
}
catch (e) {
reject(e);
}
});
}
get(key) {
return new Promise(async (resolve, reject) => {
try {
const variables = await this.list();
const data = variables.find((v) => v.env_variable === key);
if (!data)
resolve(null);
resolve(new Variable_1.default(this.client, data, this._parentServer));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = VariableManager;