From ef4ca9be4003a0a5bd5bf2c29afb2f47330705b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Tue, 9 Nov 2021 01:24:43 +0100 Subject: [PATCH] Add function to move clients to correct channels --- app.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app.ts b/app.ts index dd70607..e73dcef 100644 --- a/app.ts +++ b/app.ts @@ -313,3 +313,55 @@ async function start_match() { } } } + +async function move_clients() { + const query = gql` + query { + getTeams { + team1 { + teamspeakID + } + team2 { + teamspeakID + } + } + } + `; + + try { + const data = await request(query); + + const team1 = data.getTeams.team1; + const channel1 = await teamspeak.channelFind("Team 1"); + for (let i of team1) { + const client = await teamspeak + .getClientByUid(i.teamspeakID) + .then((client) => { + teamspeak.clientMove(client!.clid, channel1[0].cid); + }) + .catch(function (e) { + console.error(e); + }); + } + + const team2 = data.getTeams.team2; + const channel2 = await teamspeak.channelFind("Team 2"); + for (let i of team2) { + const client = await teamspeak + .getClientByUid(i.teamspeakID) + .then((client) => { + teamspeak.clientMove(client!.clid, channel2[0].cid); + }) + .catch(function (e) { + console.error(e); + }); + } + } catch (e) { + const error = get_error(e); + switch (error) { + default: + console.error(error); + break; + } + } +} -- 2.44.0