// Imports const fs = require('node:fs'); require('dotenv/config'); // Variables const owner = 'Pustur'; const repo = 'epic-store-bot'; // Init fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest`, { method: 'GET', headers: { Accept: `application/vnd.github.v3+json`, Authorization: `token ${process.env.GITHUB_TOKEN}`, }, }) .then(res => res.json()) .then(json => Promise.all( json.assets.map(asset => fetch(asset.url, { headers: { Accept: 'application/octet-stream', Authorization: `token ${process.env.GITHUB_TOKEN}`, }, }) .then(res => res.arrayBuffer()) .then(arrayBuffer => fs.promises.writeFile(asset.name, Buffer.from(arrayBuffer)), ), ), ), ) .catch(console.error);