TS-3 Bot

Hi, so I’m creating a TeamSpeak bot for a server that I am a member of using https://multivit4min.github.io/TS3-NodeJS-Library/ using that JavaScript package. I was wondering, if anyone has experience using it, and would be able to tell me how to do the following;

We need something that when someone joins a channel, if it is a waiting room that it would poke the channel admins and make them aware that someone has joined there waiting room.



Alright, just took a quick look at the library.

To check if a client has moved to a different channel you need to listen to the emitted event ClientMoved.
The event includes the properties you need (channel and client - event docs).

const { TeamSpeak } = require("ts3-nodejs-library");
const bot = new TeamSpeak({ ... });                  // init the client

const waiting_rooms = [10,29,31,52];

bot.on("clientmoved", (event) =>
   console.log(`${event.client.nickname} has switched to channel ${event.channel.name}`);

      return // poke admins

The array waiting_rooms contains the channel IDs of your waiting rooms.
If a client joins your waiting room the method will check if the current channel ID is included in the array.

Poking the admins can be done in different ways.

Either you create an array including the admin client IDs which will get poked or fetch the client list, loop through it and use the accessor servergroups to get the client’s server groups. Simply filter the clients by their group IDs or group names.

const client_list = await bot.clientList({ clientType: 0 });

for(const client of client_list)
   // client.servergroups    -> matches your group IDs or group names
   // client.clid            -> matches your admin client IDs array
   // client.databaseId         (clid != client_database_id)

   if(...)   // any option above has a match
      client.poke(`${event.client.nickname} has joined the waiting room '${event.channel.name}'`).catch((error) => console.error("Can't poke the client. Is the client still online?", error));

Catching the error if an admin can’t be poked is optional of course.

Unfortunately I couldn’t test the code, I hope there’s no typo in it.
It should give you an idea how to work with the library and which steps are required to do what you want.

Maybe there’s a faster or smarter way or existing methods to get the same result but I’m not familiar with the library.

The corresponding method to fetch the client list and servergroups can be done manually, too.
For example using the ServerQuery interface:

[email protected](1):online> clientlist
clid=999 cid=99 client_database_id=9 client_nickname=FakE client_type=0
error id=0 msg=ok

[email protected](1):online> help servergroupsbyclientid
Usage: servergroupsbyclientid cldbid={clientDBID}
error id=0 msg=ok

[email protected](1):online> servergroupsbyclientid cldbid=9
name=Some\sServer\sGroup\sName sgid=123 cldbid=9
error id=0 msg=ok
1 Like

Thanks appreciate it, still having some troubles not sure why but slowly trying to work them out.

Thats a screen shot of what i got out of your examples https://i.imgur.com/C4G3e2n.png

Another update: so i got it to work, however it pokes everyone with the channel admin tag, how would i make it so it only pokes people that have channel admin in that said channel?

with this code: https://i.imgur.com/H9g5gp6.png

Another issue, it pokes you in any channel you have channel admin in. For instance if you have channel admin in the afk channel, and someone joins it will poke you.

If anyones got a fix to this?

Oof… please do not provide code in form of a screenshot.
Use the code tags in this text editor, please.

I somehow read server groups in your inital post not channel groups. That’s my bad.

If you wanna poke clients only (with the channel admin group) which are currently in specific channels you will have to check the current channel ID of the client being poked.
The easiest way to obtain this is the same as the checkup for waiting_rooms.

const poke_rooms = [999];

for(const client of client_list)
   const current_channel = client.channelGroupInheritedChannelId;   // returns an integer not a string

   if(client.channelGroupId === "6466" && poke_rooms.includes(current_channel))

Only clients inside channels with the ID 999 as defined in the array poke_rooms will receive the poke.

1 Like
twitch instagram twitter facebook