feat: paper channel badges (#5850)

This commit is contained in:
Calum H.
2026-04-18 19:13:08 +01:00
committed by GitHub
parent ab623dc325
commit 3e32901737
18 changed files with 357 additions and 63 deletions

View File

@@ -6,8 +6,16 @@ export namespace Paper {
versions: Record<string, string[]>
}
export type BuildChannel = 'STABLE' | 'BETA' | 'ALPHA'
export type Build = {
id: number
time: string
channel: BuildChannel | string
}
export type VersionBuilds = {
builds: number[]
builds: Build[]
}
}
}

View File

@@ -1,11 +1,9 @@
import { $fetch } from 'ofetch'
import { AbstractModule } from '../../core/abstract-module'
import type { Paper } from './types'
export type { Paper } from './types'
const BASE_URL = 'https://fill.papermc.io/v3'
const PAPER_BASE_URL = 'https://fill.papermc.io'
export class PaperVersionsV3Module extends AbstractModule {
public getModuleID(): string {
@@ -16,17 +14,27 @@ export class PaperVersionsV3Module extends AbstractModule {
* Get the Paper project info including all supported Minecraft versions.
*/
public async getProject(): Promise<Paper.Versions.v3.Project> {
return $fetch<Paper.Versions.v3.Project>(`${BASE_URL}/projects/paper`)
return this.client.request<Paper.Versions.v3.Project>('/projects/paper', {
api: PAPER_BASE_URL,
version: 'v3',
method: 'GET',
skipAuth: true,
})
}
/**
* Get available Paper builds for a Minecraft version.
* Get available Paper builds for a Minecraft version (includes channel per build).
*
* Fill (`fill.papermc.io`) returns a JSON array of builds at this path — not a `{ builds }`
* wrapper like some other Paper API shapes — so we normalize to `VersionBuilds`.
*
* @param mcVersion - Minecraft version (e.g. "1.21.4")
*/
public async getBuilds(mcVersion: string): Promise<Paper.Versions.v3.VersionBuilds> {
return $fetch<Paper.Versions.v3.VersionBuilds>(
`${BASE_URL}/projects/paper/versions/${mcVersion}`,
const builds = await this.client.request<Paper.Versions.v3.Build[]>(
`/projects/paper/versions/${mcVersion}/builds`,
{ api: PAPER_BASE_URL, version: 'v3', method: 'GET', skipAuth: true },
)
return { builds }
}
}