ironie-cs2-demo-downloader/dist/app/fetchMatchFromSharecode.js
2025-05-28 00:40:46 +02:00

18 lines
715 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchMatchFromShareCode = fetchMatchFromShareCode;
const csgo_sharecode_1 = require("csgo-sharecode");
async function fetchMatchFromShareCode(shareCode, session) {
const { csgo } = session;
const decoded = (0, csgo_sharecode_1.decodeMatchShareCode)(shareCode);
return new Promise((resolve, reject) => {
csgo.once('matchList', (matches) => {
const match = matches.find((m) => m.matchid === decoded.matchId.toString());
if (!match)
return reject(new Error('❌ Kein Match gefunden'));
resolve(match);
});
csgo.requestGame(shareCode);
});
}