35 lines
745 B
JavaScript
35 lines
745 B
JavaScript
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|