diff --git a/bot.js b/bot.js index a5afb35..f00cf94 100644 --- a/bot.js +++ b/bot.js @@ -47,10 +47,11 @@ const positionUpdate = async () => { const position = data.onlinePosition; - dataUpdate(data); - const serverGroupsById = await teamspeak.serverGroupsByClientId(clientDbid.cldbid); + dataUpdate(data, serverGroupsById); + + if (position) { if (serverGroupsById.some((item)=> item.name===position)){ return; @@ -120,7 +121,7 @@ const removePosition = async (client) => { } } -const dataUpdate = async (data) => { +const dataUpdate = async (data, serverGroupsById) => { const controllerStatus = data.controllerStatus === "HOME" ? 1 : 0; const rating = data.rating; @@ -240,7 +241,7 @@ teamspeak.on("clientconnect", async (connected) => { return; } - dataUpdate(data); + dataUpdate(data, serverGroupsById); }) teamspeak.on("clientdisconnect", async (connected) => {