pterowrap
Version:
A node.js wrapper for Pterodactyl API
39 lines (38 loc) • 1.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Database_1 = __importDefault(require("../../../structures/client/server/Database"));
class DatabaseManager {
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}/databases`, parameters: options });
const r = [];
for (let i = 0; i < list.data.length; i++) {
r.push(new Database_1.default(this.client, list.data[i], this._parentServer));
}
resolve(r);
}
catch (e) {
reject(e);
}
});
}
create(params) {
return new Promise(async (resolve, reject) => {
try {
resolve(new Database_1.default(this.client, (await this.client.call({ endpoint: `servers/${this._parentServer.identifier}/databases`, method: "POST", body: params })).data, this._parentServer));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = DatabaseManager;