papermc-api
Version:
Its a PaperMC Downloads API client for node.js.
38 lines (37 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Build = void 0;
class Build {
constructor(project_id, project_name, version, build, time, channel, promoted, changes, downloads) {
this.project_id = project_id;
this.project_name = project_name;
this.version = version;
this.build = build;
this.time = time;
this.channel = channel;
this.promoted = promoted;
this.changes = changes;
this.downloads = downloads;
}
getDownloadUrl(download) {
if (!download || !Object.keys(this.downloads).includes(download)) {
return `https://papermc.io/api/v2/projects/${this.project_id}/versions/${this.version}/builds/${this.build}/downloads/${this.downloads.application.name}`;
}
else {
return `https://papermc.io/api/v2/projects/${this.project_id}/versions/${this.version}/builds/${this.build}/downloads/${this.downloads[download].name}`;
}
}
static fromRaw(raw) {
if (Array.isArray(raw)) {
let builds = [];
for (let build of raw) {
builds.push(Build.fromRaw(build));
}
return builds;
}
else {
return new Build(raw.project_id, raw.project_name, raw.version, raw.build, raw.time, raw.channel, raw.promoted, raw.changes, raw.downloads);
}
}
}
exports.Build = Build;