-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.js
More file actions
18 lines (17 loc) · 903 Bytes
/
version.js
File metadata and controls
18 lines (17 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { getOrCreateVersionData, updateVersion } from "."
import { allLoaders } from "./loader"
export async function getFromModrinth(slug) {
let versions = await fetch(`https://api.modrinth.com/v2/project/${slug}/version`).then(res => res.json()).catch(err => console.log(err))
if (!versions) return
for (let { game_versions, loaders, version_number, status, id } of versions) {
if (status != 'listed') continue
for (let gameVersion of game_versions) {
let d = getOrCreateVersionData(gameVersion)
if (!d[slug]) d[slug] = {}
for (let loader of Array.intersect(loaders, allLoaders))
if (!d[slug][loader])
d[slug][loader] = { version: version_number.endsWith(loader) ? version_number.slice(0, version_number.length - loader.length - 1) : version_number, id: id }
}
}
updateVersion(slug)
}