|
2 | 2 |
|
3 | 3 | import lombok.extern.slf4j.Slf4j; |
4 | 4 | import net.dv8tion.jda.api.EmbedBuilder; |
| 5 | +import net.dv8tion.jda.api.JDA; |
5 | 6 | import net.dv8tion.jda.api.entities.*; |
6 | 7 | import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; |
7 | 8 | import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent; |
@@ -79,19 +80,22 @@ public SubmissionControlsManager(Guild guild, ThreadChannel channel) { |
79 | 80 | public void sendControls() { |
80 | 81 | ThreadChannel thread = this.guild.getThreadChannelById(this.submission.getThreadId()); |
81 | 82 | if (thread == null) return; |
82 | | - this.removeThreadMembers(thread, this.config); |
83 | 83 | thread.getManager().setName(String.format("%s %s", SUBMISSION_PENDING, thread.getName())).queue(); |
84 | 84 | thread.sendMessage(config.getQOTWReviewRole().getAsMention()) |
85 | 85 | .setEmbeds(this.buildSubmissionControlEmbed()) |
86 | 86 | .setActionRows(this.buildInteractionControls()).queue(); |
| 87 | + this.removeThreadOwner(thread.getJDA(), thread); |
87 | 88 | log.info("Sent Submission Controls to thread {}", thread.getName()); |
| 89 | + |
88 | 90 | } |
89 | 91 |
|
90 | | - private void removeThreadMembers(ThreadChannel thread, QOTWConfig config) { |
91 | | - thread.getThreadMembers() |
92 | | - .stream() |
93 | | - .filter(m -> !m.getMember().getRoles().contains(config.getQOTWReviewRole()) && !m.getMember().getUser().isBot()) |
94 | | - .forEach(m -> thread.removeThreadMember(m.getUser()).queue()); |
| 92 | + private void removeThreadOwner(JDA jda, ThreadChannel thread) { |
| 93 | + DbHelper.doDaoAction(QOTWSubmissionRepository::new, dao -> { |
| 94 | + Optional<QOTWSubmission> submissionOptional = dao.getSubmissionByThreadId(thread.getIdLong()); |
| 95 | + submissionOptional.ifPresent(submission -> jda.retrieveUserById(submission.getAuthorId()).queue( |
| 96 | + author -> thread.removeThreadMember(author).queue() |
| 97 | + )); |
| 98 | + }); |
95 | 99 | } |
96 | 100 |
|
97 | 101 | /** |
|
0 commit comments