jspteroapi
Version:
A pterodactyl v1 api using undici
90 lines (89 loc) • 3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.nestMethods = void 0;
const Functions_1 = require("../../modules/Functions");
class nestMethods {
application;
constructor(application) {
this.application = application;
}
/**
* @internal
*/
getNests = async (options) => {
return this.application.request('GET', null, '', `/api/application/nests${(0, Functions_1.makeOptions)(options)}`);
};
/**
* @param options - Include information about: eggs or servers
* @returns Array of nests
* @example
* ```ts
* const res = await app.getAllNests() // res = Nest[]
* ```
* @example
* ```ts
* app.getAllNests().then((res) => console.log(res)) // res = Nest[]
* ```
*/
getAllNests = async (options) => {
return await (0, Functions_1.paginate)(this.getNests.bind(this), {
includes: { ...options }
});
};
/**
* @param nestId - The nest ID to get the details of.
* @param options - Include information about: eggs or servers
* @returns Nest details
* @example
* ```ts
* const res = await app.getNestInfo(1) // res = NestAttributes
* ```
* @example
* ```ts
* app.getNestInfo(1).then((res) => console.log(res)) // res = NestAttributes
* ```
*/
getNestInfo = async (nestId, options) => {
return this.application.request('GET', null, 'attributes', `/api/application/nests/${nestId}${(0, Functions_1.makeOptions)({
includes: { ...options }
})}`);
};
/**
* @param nestId - The nest ID to get the details of.
* @param options - Include information about: nest or servers or variables
* @returns
* @example
* ```ts
* const res = await app.getAllNestEggs(1) // res = Egg[]
* ```
* @example
* ```ts
* app.getAllNestEggs(1).then((res) => console.log(res)) // res = Egg[]
* ```
*/
getAllNestEggs = async (nestId, options) => {
return this.application.request('GET', null, 'data', `/api/application/nests/${nestId}/eggs${(0, Functions_1.makeOptions)({
includes: { ...options }
})}`);
};
/**
* @param nestId - The nest ID to get the details of.
* @param eggId - Egg ID to use when installing the server
* @param options - Include information about: nest or servers or variables
* @returns
* @example
* ```ts
* const res = await app.getEggInfo(1, 1) // res = EggAttributes
* ```
* @example
* ```ts
* app.getEggInfo(1, 1).then((res) => console.log(res)) // res = EggAttributes
* ```
*/
getEggInfo = async (nestID, eggId, options) => {
return this.application.request('GET', null, 'attributes', `/api/application/nests/${nestID}/eggs/${eggId}${(0, Functions_1.makeOptions)({
includes: { ...options }
})}`);
};
}
exports.nestMethods = nestMethods;