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

Problem with ChannelProperty Set Channel Temporary

Open Veqtive opened this issue 4 years ago • 6 comments

Hey there, I'm having an issue with the ChannelProperty CHANNEL_FLAG_TEMPORARY.

What am I trying to do: If a specified user lefts the teamspeak server the channel is supposed to become temporary. I tried this using: channeledit.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "0"); channeledit.put(ChannelProperty.CHANNEL_FLAG_TEMPORARY, "1");

Even without setting Permanent to 0 or setting semi permanent to 0, too, nothing worked. I just get this error:

[2020-04-27 22:07:06.926] [SEVERE] TS3 command error: {msg=invalid parameter, id=1538}

What am I doing wrong?

My Code so far for the client leave event:

` public void onClientLeave(ClientLeaveEvent e) { int clientid = e.getClientId(); if (online.containsKey(clientid)) {

				String clientName = online.get(clientid);
				System.out.println(clientName);
				String ChannelName = "Administration - " + clientName;
				int channel = Load.api.getChannelByNameExact(ChannelName, true).getId();

				HashMap<ChannelProperty, String> channeledit = new HashMap<>();
				channeledit.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "0");
				channeledit.put(ChannelProperty.CHANNEL_FLAG_TEMPORARY, "1");
				Load.asyncapi.editChannel(channel, channeledit);

			} else {
				System.out.println("[INFO] Teammitglied hat keinen Channel");
			}

		}`

Veqtive avatar Apr 27 '20 20:04 Veqtive

You cannot set Permanent and Temporary at the same time

NIFO43 avatar Apr 30 '20 16:04 NIFO43

Set properties.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "1"); to make it permanent and properties.put(ChannelProperty.CHANNEL_FLAG_TEMPORARY, "1"); to set it temporary

NIFO43 avatar Apr 30 '20 16:04 NIFO43

Set properties.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "1"); to make it permanent and properties.put(ChannelProperty.CHANNEL_FLAG_TEMPORARY, "1"); to set it temporary

I already have tried this, too (as one can see above in my question). But regardless of just setting Temporary to "1" or setting other flags to "0" I get the same error

Veqtive avatar Apr 30 '20 19:04 Veqtive

Hi!

Turns out that CHANNEL_FLAG_TEMPORARY cannot be used in conjunction with most channel commands. Just another instance of the TS3 server being weird, I guess :/

Instead, the way to make a channel temporary is to set both CHANNEL_FLAG_PERMANENT and CHANNEL_FLAG_SEMI_PERMANENT to "0".

That is, change your code to

HashMap<ChannelProperty, String> channeledit = new HashMap<>();
channeledit.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "0");
channeledit.put(ChannelProperty.CHANNEL_FLAG_SEMI_PERMANENT, "0");
Load.asyncapi.editChannel(channel, channeledit);

and it should make the channel temporary.

Keep in mind that a channel that is temporary and does not contain any clients will be deleted from the TS3 server. You may want to move the query into the channel you're editing using TS3Api#moveQuery to prevent this from happening.

rogermb avatar May 04 '20 23:05 rogermb

Hey, thanks for your answer. I've tried your suggestion but it did not work. I am also not getting any kind of error, the query just does not change the channel properties.

And yes, I know that the channel is going to be deleted if set to temporary and nobody is in there, this is exactly what I've had in mind while making this query

Veqtive avatar May 05 '20 10:05 Veqtive

Hmm... are you sure that your code to make the channel temporary gets executed?

You could also turn on the query command logging to check what commands get sent to the server and what kinds of responses you get back.

rogermb avatar May 05 '20 13:05 rogermb