This repository has been archived on 2023-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
fortnite-metrics-grafana/index.js

35 lines
745 B
JavaScript
Raw Normal View History

2023-04-09 06:49:29 +00:00
require("dotenv").config();
const { Client: FortniteAPI, Language } = require("fnapicom");
const ACCOUNTS_TO_TRACK = process.env.FORTNITE_USERNAMES.includes(",")
? process.env.FORTNITE_USERNAMES.split(",")
: [process.env.FORTNITE_USERNAMES];
const client = new FortniteAPI({
language: Language.English,
apiKey: process.env.API_KEY,
});
trackAccounts();
setInterval(() => {
trackAccounts();
}, 60_000);
async function trackAccounts() {
for (const username of ACCOUNTS_TO_TRACK) {
try {
const account = await client.brStats({
name: username,
});
if (account.status !== 200) {
console.error(`Error: ${account.status}`);
continue;
}
console.log("works");
} catch (error) {
console.error(error);
}
}
}