When i start bot console say:
Online with undefined/5
and when 10 secconds are passed give this error:
undefined:1
[object Promise]
^
SyntaxError: Unexpected token o in JSON at position 1
My Code:
let jogadores
client.on("ready", async () => {
async function players_online() {
const response = fetch(`http://ip:port/dynamic.json`);
const data = JSON.parse(response);
jogadores = data.clients;
}
async function autoconnect() {
if (jogadores === -1) {
console.log('Offline');
} else {
console.log('Online with ' + jogadores + '/5')
}
}
autoconnect()
setInterval(() => {
client.user.setStatus('dnd');
client.user.setActivity(`Online with ${jogadores} players.`, { type: 'PLAYING' })
players_online()
}, 10000)
})