How to move a channel to another category and sort this category by name #2435
-
Hello everyone, I want to move a channel to a different category and sort all channels inside this category by name. I am able to do that seperately but it won't work if I try to combine these tasks. Moving the channel:
Sorting the Category:
With ChannelComparator():
If I sort after moving the channel the categorys channel list doesn't contain the new channel. I was able to work around that by creating a thread, wait a few seconds and then sort inside that thread. If I just use a Thread.sleep() the categorys channel list won't be updated. What do I miss? Can I force the categorys channel list to be updated? Is there another way? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This might work: channel.getManager().setParent(cat).delay(500, TimeUnit.MILLISECONDS).queue(v -> {
cat.modifyTextChannelPositions().sortOrder(Comparator.comparing(GuildChannel::getName)).queue();
});
|
Beta Was this translation helpful? Give feedback.
This might work:
setParent(cat)
moves the channel into the categorydelay(500, MILLISECONDS)
makes the callback run half a second later (to avoid race conditions)sortOrder(Comparator.comparing(GuildChannel::getName))
sorts by name