These are chat archives for TheHolyWaffle/TeamSpeak-3-Java-API

Jan 2017
JoKer96 | 😴
Jan 30 2017 02:54

Hey there, i have another Problem.
I try to create a Subchannel, move a client, from the channel above in the subchannel, change the channel to a temporary one and give the client a specific channel group.
But it won't work, the channel is created, and modified to a temporary one, but noething more...
Here is my Code:

// ---- Channel Creation ----
System.out.println("Create Channel");
// Let's customize our channel
final HashMap<ChannelProperty, String> properties = new HashMap<ChannelProperty, String>();
// Make it a permanent channel
properties.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "1");
// Make it a subchannel of the channel, the user joint.
int mainChannel = headChannelId;
properties.put(ChannelProperty.CPID, String.valueOf(mainChannel));

// Create the (sub-)channel
String name = "";
try {
    name = Core.asyncApi.getChannelInfo(headChannelId).get().getName() + " Ch1";
} catch (InterruptedException ex) {

Core.asyncApi.createChannel(name, properties);

// ---- Move user to the created (sub-)channel ----
System.out.println("Move User");
int newChannelId = -1;
try {
newChannelId = Core.asyncApi.getChannelByNameExact(name, false).get().getId();
} catch (InterruptedException ex) {

if (newChannelId != -1) {
    Core.asyncApi.moveClient(clientId, newChannelId);

// ---- Make the channel temporary ----
System.out.println("Make Channel temporary");
HashMap<ChannelProperty, String> newProperties = new HashMap<ChannelProperty, String>();

newProperties.put(ChannelProperty.CHANNEL_FLAG_PERMANENT, "0");
newProperties.put(ChannelProperty.CHANNEL_FLAG_TEMPORARY, "1");

Core.asyncApi.editChannel(newChannelId, newProperties);

// ---- Set the channel-group for the user ----
System.out.println("Set the Channelgroup");
int channelGroupId = 28;
int channelId = newChannelId;
int clientDBId = clientId;

Core.asyncApi.setClientChannelGroup(channelGroupId, channelId, clientDBId);

// ---- Done ----

Maybe you can help me out?

The code again, this time on hastebin...
Roger Baumgartner
Jan 30 2017 12:18
Dude, why are you using the asynchronous API like this??
Core.asyncApi.createChannel(name, properties);
is not done when you call
newChannelId = Core.asyncApi.getChannelByNameExact(name, false).get().getId();
And createChannel already returns the ID of the new channel, so that second API call is unnecessary
The whole channel properties map also isn't needed. New channels are temporary by default.
Seriously, just use the normal synchronous API in your code and your problems will magically solve temselves :stuck_out_tongue: