From 48fdc3b168e40b70028b31fa686a6f8abc20256b Mon Sep 17 00:00:00 2001 From: Roman Makeev <57789105+makeevrserg@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:09:13 +0000 Subject: [PATCH] fix fetch of discord users (#69) --- gradle.properties | 2 +- .../command/discordlink/job/DiscordLinkJob.kt | 14 ++++++++------ .../towny/discord/job/TownyDiscordRoleJob.kt | 14 +++++++++----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index ce3b3db9..7a915c3e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ makeevrserg.java.ktarget=21 # Project makeevrserg.project.name=AspeKt makeevrserg.project.group=ru.astrainteractive.aspekt -makeevrserg.project.version.string=2.23.2 +makeevrserg.project.version.string=2.23.3 makeevrserg.project.description=Essentials plugin for EmpireProjekt makeevrserg.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com makeevrserg.project.url=https://empireprojekt.ru diff --git a/modules/discordlink/src/main/kotlin/ru/astrainteractive/aspekt/module/adminprivate/command/discordlink/job/DiscordLinkJob.kt b/modules/discordlink/src/main/kotlin/ru/astrainteractive/aspekt/module/adminprivate/command/discordlink/job/DiscordLinkJob.kt index 08a10726..d8e9828e 100644 --- a/modules/discordlink/src/main/kotlin/ru/astrainteractive/aspekt/module/adminprivate/command/discordlink/job/DiscordLinkJob.kt +++ b/modules/discordlink/src/main/kotlin/ru/astrainteractive/aspekt/module/adminprivate/command/discordlink/job/DiscordLinkJob.kt @@ -38,6 +38,7 @@ internal class DiscordLinkJob( .linkedAccounts .keys .toSet() + val verifiedDiscordUsersChunks = verifiedDiscordUsers.chunked(32) if (verifiedDiscordUsers.isEmpty()) return discordRoleController.removeRoleFromMembersWithRole( @@ -45,12 +46,13 @@ internal class DiscordLinkJob( roleId = discordRoleId, guild = guild ) - - discordRoleController.addRoleToMembers( - memberIds = verifiedDiscordUsers, - roleId = discordRoleId, - guild = guild - ) + verifiedDiscordUsersChunks.forEach { chunk -> + discordRoleController.addRoleToMembers( + memberIds = chunk.toSet(), + roleId = discordRoleId, + guild = guild + ) + } } private suspend fun processLuckPermsRoles() { diff --git a/modules/towny-discord/src/main/kotlin/ru/astrainteractive/aspekt/module/towny/discord/job/TownyDiscordRoleJob.kt b/modules/towny-discord/src/main/kotlin/ru/astrainteractive/aspekt/module/towny/discord/job/TownyDiscordRoleJob.kt index 9e95e195..e10eeed7 100644 --- a/modules/towny-discord/src/main/kotlin/ru/astrainteractive/aspekt/module/towny/discord/job/TownyDiscordRoleJob.kt +++ b/modules/towny-discord/src/main/kotlin/ru/astrainteractive/aspekt/module/towny/discord/job/TownyDiscordRoleJob.kt @@ -41,16 +41,20 @@ internal class TownyDiscordRoleJob( .map { entry -> entry.value } .toSet() + val mayorsDiscordIdsChunked = mayorsDiscordIds.chunked(32) + discordRoleController.removeRoleFromMembersWithRole( whitelistedUserIds = mayorsDiscordIds, roleId = configuration.towny.leaderRoleConfiguration.roleId, guild = guild ) - discordRoleController.addRoleToMembers( - memberIds = mayorsDiscordIds, - roleId = configuration.towny.leaderRoleConfiguration.roleId, - guild = guild - ) + mayorsDiscordIdsChunked.forEach { chunk -> + discordRoleController.addRoleToMembers( + memberIds = chunk.toSet(), + roleId = configuration.towny.leaderRoleConfiguration.roleId, + guild = guild + ) + } } } }