Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ private void handleVoiceChannelLeave(AudioChannelUnion channelLeft) {
if (!eventHappenOnDynamicRootChannel(channelLeft)) {
logger.debug("Event happened on left channel {}", channelLeft);

if (hasMembers(channelLeft)) {
logger.debug("Voice channel {} not empty, so not doing anything.",
channelLeft.getName());
return;
}

channelLeft.asVoiceChannel().getHistory().retrievePast(2).queue(messages -> {
if (messages.size() > 1) {
archiveDynamicVoiceChannel(channelLeft);
Expand Down Expand Up @@ -124,16 +130,13 @@ private void moveMember(Guild guild, Member member, AudioChannel channel) {
member.getNickname(), channel.getName(), error));
}

private boolean hasMembers(AudioChannelUnion channel) {
return !channel.getMembers().isEmpty();
}

private void archiveDynamicVoiceChannel(AudioChannelUnion channel) {
int memberCount = channel.getMembers().size();
String channelName = channel.getName();

if (memberCount > 0) {
logger.debug("Voice channel {} not empty ({} members), so not removing.", channelName,
memberCount);
return;
}

Optional<Category> archiveCategoryOptional = channel.getGuild()
.getCategoryCache()
.stream()
Expand Down
Loading