From 46d267d71344ab5b8abc192d86662e1e0918e961 Mon Sep 17 00:00:00 2001 From: megoRU Date: Thu, 18 Jan 2024 21:10:57 +0300 Subject: [PATCH] New Update 1. Fix --- src/main/java/main/config/BotStart.java | 4 ---- .../service/ParticipantsUpdaterService.java | 21 +++++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/main/config/BotStart.java b/src/main/java/main/config/BotStart.java index 85cc21f..70bdc30 100644 --- a/src/main/java/main/config/BotStart.java +++ b/src/main/java/main/config/BotStart.java @@ -90,15 +90,11 @@ private void startBot() { List cacheFlags = new ArrayList<>( Arrays.asList( - CacheFlag.ONLINE_STATUS, - CacheFlag.VOICE_STATE, CacheFlag.ROLE_TAGS, CacheFlag.ACTIVITY, CacheFlag.MEMBER_OVERRIDES)); jdaBuilder.disableCache(cacheFlags); - jdaBuilder.setMemberCachePolicy(MemberCachePolicy.ALL); - jdaBuilder.setChunkingFilter(ChunkingFilter.ALL); jdaBuilder.enableIntents(intents); jdaBuilder.setAutoReconnect(true); jdaBuilder.setStatus(OnlineStatus.ONLINE); diff --git a/src/main/java/main/service/ParticipantsUpdaterService.java b/src/main/java/main/service/ParticipantsUpdaterService.java index 1217015..da4dc36 100644 --- a/src/main/java/main/service/ParticipantsUpdaterService.java +++ b/src/main/java/main/service/ParticipantsUpdaterService.java @@ -72,8 +72,15 @@ public void update(JDA jda) { if (isForSpecificRole) { Role roleGiveaway = jda.getRoleById(giveaway.getRoleId()); - List membersWithRoles = guild.getMembersWithRoles(roleGiveaway); - for (Member member : membersWithRoles) { + long startTime = System.currentTimeMillis(); + List members = guild.loadMembers().get(); + long endTime = System.currentTimeMillis(); + long timeElapsed = endTime - startTime; + System.out.printf("\nЗамер выполнение метода: Guild_ID: %s, Size: %s, Время: %s ms", + guildIdLong, + members.size(), + timeElapsed); + for (Member member : members) { boolean contains = member.getRoles().contains(roleGiveaway); if (!contains) { userList.remove(member.getId()); @@ -83,8 +90,14 @@ public void update(JDA jda) { if (forbiddenRole != null) { Role roleGiveaway = jda.getRoleById(giveaway.getForbiddenRole()); - List membersWithRoles = guild.getMembersWithRoles(roleGiveaway); - for (Member member : membersWithRoles) { + long startTime = System.currentTimeMillis(); + List members = guild.loadMembers().get(); + long endTime = System.currentTimeMillis(); + long timeElapsed = endTime - startTime; + System.out.printf("\nЗамер выполнение метода: Guild_ID: %s, Size: %s, Время: %s ms", + guildIdLong, + members.size(), + timeElapsed); for (Member member : members) { boolean contains = member.getRoles().contains(roleGiveaway); if (contains) { userList.remove(member.getId());