This repository was archived by the owner on Feb 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/main/kotlin/net/perfectdreams/loritta/helper/listeners Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,22 @@ class ComponentInteractionListener(val m: LorittaHelper) : ListenerAdapter() {
403403 // We need to add the user to the thread after it is unarchived!
404404 threadChannel.addThreadMember(event.user).await()
405405
406+ if (systemInfo is HelpDeskTicketSystem ) {
407+ val supportRole = member.guild.getRoleById(systemInfo.supportRoleId)
408+
409+ if (supportRole != null ) {
410+ // Attempt to remove any thread member that isn't the user or staff
411+ val threadMembers = threadChannel.retrieveThreadMembers().await()
412+ for (threadMember in threadMembers) {
413+ if (threadMember.idLong != member.idLong && ! threadMember.member.roles.contains(supportRole)) {
414+ threadChannel.removeThreadMember(threadMember.user).await()
415+ }
416+ }
417+ } else {
418+ logger.warn(" Missing role ${systemInfo.supportRoleId} in ${event.guild.idLong} ! Bug?" )
419+ }
420+ }
421+
406422 cachedTickets.tickets[event.user.idLong] = TicketsCache .DiscordThreadTicketData (ticketThreadId)
407423
408424 transaction(m.databases.helperDatabase) {
You can’t perform that action at this time.
0 commit comments