CatBoat-Launcher/modules/mojangAPI.js
Azure 13c6f14886 Added few internals modules
-  Added game setting parser/stringifier 📝
  -  Added skin upload using mojang api 👾
  -  Added server ping using mcsrvstat.us 🖥️
  -  Added api and endpoints to the config ⚙️
  -  Added syscalls for modules 🧩
2025-04-29 11:08:58 +02:00

26 lines
794 B
JavaScript

const fs = require("node:fs")
const path = require("node:path")
const config = require("../config.json")
async function uploadSkin(filePath, variant, token) {
const form = new FormData()
form.append("variant", variant)
form.append("file", fs.readFileSync(filePath), path.parse(filePath).base)
const response = await fetch(`${config.minecraft.services.api.base}${config.minecraft.services.api.endpoints.uploadSkin}`, {
method: "POST",
body: form,
headers: {
Authorization: `Bearer ${token}`
}
})
if (response.ok) {
const json = await response.json()
return json
} else {
throw new Error(`Error uploading skin: ${response.status} ${response.statusText}`)
}
}
module.exports = {
uploadSkin
}