edit VoiceLobby Module to support tempData

This commit is contained in:
Hiajen Hiajen 2021-04-05 13:46:02 +02:00
parent db37d6ce9a
commit 1a8fe6c8ad

View file

@ -31,7 +31,6 @@ public class VoiceLobby extends SuperModule {
private long groupCategory;
private long launchpadChannel;
private HashSet<Long> tmpChannel = new HashSet<>();
private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -98,7 +97,7 @@ public class VoiceLobby extends SuperModule {
// move User
event.getGuild().moveVoiceMember(((GuildMessageReceivedEvent) event).getMember(), newChannel).queue();
tmpChannel.add(newChannel.getIdLong());
((HashSet<Long>)getTemporaryData().get("tmpChannel")).add(newChannel.getIdLong());
} else {
thisEvent.getChannel().sendMessage("Please Join a Voice Channel first!").queue(e -> e.delete().queueAfter(1, TimeUnit.MINUTES));
@ -185,7 +184,7 @@ public class VoiceLobby extends SuperModule {
//check if user left a temp channel
if ((thisEvent.getChannelLeft() != null && thisEvent.getChannelLeft().getParent().getIdLong() == groupCategory)) {
//check if channel is now empty
if (thisEvent.getChannelLeft().getMembers().size() < 1 && tmpChannel.contains(thisEvent.getChannelLeft().getIdLong())) {
if (thisEvent.getChannelLeft().getMembers().size() < 1 && ((HashSet<Long>)getTemporaryData().get("tmpChannel")).contains(thisEvent.getChannelLeft().getIdLong())) {
logger.debug("may remove channel: " + thisEvent.getChannelLeft().getId());
//wait for 30 seconds and check again
@ -197,7 +196,7 @@ public class VoiceLobby extends SuperModule {
logger.debug("remove channel: " + thisEvent.getChannelLeft().getId());
thisEvent.getChannelLeft().delete().queue();
tmpChannel.remove(thisEvent.getChannelLeft().getIdLong());
((HashSet<Long>)getTemporaryData().get("tmpChannel")).remove(thisEvent.getChannelLeft().getIdLong());
} else {
logger.debug("dont remove channel: " + thisEvent.getChannelLeft().getId());
}
@ -215,7 +214,7 @@ public class VoiceLobby extends SuperModule {
// move User
event.getGuild().moveVoiceMember(thisEvent.getEntity(), newChannel).queue();
tmpChannel.add(newChannel.getIdLong());
((HashSet<Long>)getTemporaryData().get("tmpChannel")).add(newChannel.getIdLong());
}
}
}