Unarchiving a privat thread channel and adding a new member fails #2533
-
I'm intending to work with threads in my setup and want them to unarchive if i need to perform actions on them. So i implemented the unarchiving with Looking into discord i see the thread being active again. So what would the correct way be to unarchive the thread? I get the feeling this is some chaching problem?! Or are there any scenarios where my intended process just will not work? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can try something like this: channel.getManager().setArchived(false)
.delay(Duration.ofSeconds(1)) // 1 second later
.map(v -> jda.getThreadChannelById(channel.getIdLong())) // get fresh instance from cache
.flatMap(thread -> thread.addThreadMember(user)) // then add a member
.queue(); // important not to use complete() here so cache can catch up! The issue here is definitely the cache, archived threads are never cached by JDA, so the state of that object is never updated. Besides that, discord also has some race-conditions related to archiving, so it is best to wait a little before adding a new member. |
Beta Was this translation helpful? Give feedback.
You can try something like this:
The issue here is definitely the cache, archived threads are never cached by JDA, so the state of that object is never updated. Besides that, discord also has some race-conditions related to archiving, so it is best to wait a little before adding a new member.