Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ChannelProperty Set Channel Temporary #361

Open
Veqtive opened this issue Apr 27, 2020 · 6 comments
Open

Problem with ChannelProperty Set Channel Temporary #361

Veqtive opened this issue Apr 27, 2020 · 6 comments
Labels

Comments

@Veqtive
Copy link

Veqtive commented Apr 27, 2020

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");
			}

		}`
@NIFO43
Copy link

NIFO43 commented Apr 30, 2020

You cannot set Permanent and Temporary at the same time

@NIFO43
Copy link

NIFO43 commented Apr 30, 2020

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

@Veqtive
Copy link
Author

Veqtive commented Apr 30, 2020

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

@rogermb
Copy link
Collaborator

rogermb commented May 4, 2020

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.

@Veqtive
Copy link
Author

Veqtive commented May 5, 2020

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

@rogermb
Copy link
Collaborator

rogermb commented May 5, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants