use of net.dv8tion.jda.api.events.thread.member.ThreadMemberLeaveEvent in project JDA by DV8FromTheWorld.
the class ThreadMembersUpdateHandler method handleRemovedThreadMembers.
private void handleRemovedThreadMembers(ThreadChannelImpl thread, List<Long> removedMemberIds) {
CacheView.SimpleCacheView<ThreadMember> view = thread.getThreadMemberView();
// Store the removed threads into a map so that we can provide them in the events later.
// We don't want to dispatch the events from inside the writeLock
TLongObjectMap<ThreadMember> removedThreadMembers = new TLongObjectHashMap<>();
try (UnlockHook lock = view.writeLock()) {
for (long threadMemberId : removedMemberIds) {
ThreadMember threadMember = view.getMap().remove(threadMemberId);
removedThreadMembers.put(threadMemberId, threadMember);
}
}
for (long threadMemberId : removedMemberIds) {
api.handleEvent(new ThreadMemberLeaveEvent(api, responseNumber, thread, threadMemberId, removedThreadMembers.remove(threadMemberId)));
}
}
Aggregations