pterowrap
Version:
A node.js wrapper for Pterodactyl API
54 lines (53 loc) • 1.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Server_1 = __importDefault(require("../../structures/application/Server"));
const Util_1 = __importDefault(require("../../utils/Util"));
class ServerManager {
constructor(client) {
this.client = client;
}
list(options = {}) {
return new Promise(async (resolve, reject) => {
try {
resolve(await Util_1.default.handlePagination(this.client, "servers", options, Server_1.default));
}
catch (e) {
reject(e);
}
});
}
get(id, options = {}) {
return new Promise(async (resolve, reject) => {
try {
resolve(new Server_1.default(this.client, await this.client.call({ endpoint: "servers/" + id, parameters: options })));
}
catch (e) {
reject(e);
}
});
}
getByExternalId(id, options = {}) {
return new Promise(async (resolve, reject) => {
try {
resolve(new Server_1.default(this.client, await this.client.call({ endpoint: "servers/external/" + id, parameters: options })));
}
catch (e) {
reject(e);
}
});
}
create(params) {
return new Promise(async (resolve, reject) => {
try {
resolve(new Server_1.default(this.client, await this.client.call({ endpoint: "servers", method: "POST", body: params })));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = ServerManager;