TeamSpeak-3-Java-API icon indicating copy to clipboard operation
TeamSpeak-3-Java-API copied to clipboard

channel.getTotalClients() showing wrong numbers

Open qeinz opened this issue 4 years ago • 2 comments

My bot gives me -1 as client value, but we are 4 clients in the channel.

I use the latest API version.

qeinz avatar Jan 06 '22 04:01 qeinz

I'm not sure what the purpose of the TOTAL_CLIENTS flag in the teamspeak api is, but it wouldn't surprise me if it has some obscure function aside from conveying the number of clients in a channel. For this java wrapper api, the Channel objects aren't updated all the time, nor are client objects, as they are merely local java representations of the channel or client at a particular instant. You'll want to make sure that you have the most up-to-date info by calling TS3Api#getChannels() or #getChannelByName, or whatever method you choose, then perhaps that method will return a useful value. I'm more partial to using TS3Api#getClients(), then filtering by channel instead, since I will use other client info, but I don't know what your intent is for that information.

astrolamb-gaming avatar Jan 07 '22 01:01 astrolamb-gaming

it was intended, if someone has a music bot in the channel, that this, if all other users leave the channel, he was moved back to his home.

Have solved it so:

    public static void moveTeamBots() {

        for (Client clients : Main.api.getClients()) {
            if (clients.isInServerGroup(GroupIdService.teammusic) && (clients.getChannelId() != ChannelIdService.musikAfkChannel_ID)) {
                String tmp = "alone";

                for (Client clients2 : Main.api.getClients()) {
                    if (!clients2.isInServerGroup(GroupIdService.teammusic)) {
                        if (clients.getChannelId() == clients2.getChannelId()) {
                            tmp = "not";
                        }
                    }
                }

                if (tmp.equalsIgnoreCase("alone")) Main.api.moveClient(clients.getId(),
                        ChannelIdService.musikAfkChannel_ID);

            }


        }
    }

i know, funny way to solve my problem xD

qeinz avatar Aug 04 '23 21:08 qeinz