Skip to content

Commit ef4e99b

Browse files
The bot now just removes permissions instead of removing the thread owner from the submission thread
1 parent cf99f6e commit ef4e99b

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/main/java/net/javadiscord/javabot/systems/qotw/QOTWCloseSubmissionsJob.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import net.dv8tion.jda.api.JDA;
5+
import net.dv8tion.jda.api.Permission;
56
import net.dv8tion.jda.api.entities.Message;
67
import net.dv8tion.jda.api.entities.MessageChannel;
78
import net.dv8tion.jda.api.interactions.components.ActionRow;
@@ -15,6 +16,7 @@
1516
import org.quartz.JobExecutionException;
1617

1718
import java.sql.SQLException;
19+
import java.util.Collections;
1820

1921
/**
2022
* Job which disables the Submission button.
@@ -27,6 +29,9 @@ protected void execute(JobExecutionContext context, JDA jda) throws JobExecution
2729
// Disable 'Submit your Answer' button on latest QOTW
2830
var config = Bot.config.get(guild);
2931
var qotwConfig = config.getQotw();
32+
qotwConfig.getSubmissionChannel().getManager()
33+
.putRolePermissionOverride(guild.getIdLong(), Collections.emptySet(), Collections.singleton(Permission.MESSAGE_SEND_IN_THREADS))
34+
.queue();
3035
if (config.getModeration().getLogChannel() == null) continue;
3136
if (qotwConfig.getSubmissionChannel() == null || qotwConfig.getQuestionChannel() == null) continue;
3237
var message = getLatestQOTWMessage(qotwConfig.getQuestionChannel(), qotwConfig, jda);

src/main/java/net/javadiscord/javabot/systems/qotw/QOTWJob.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import lombok.extern.slf4j.Slf4j;
44
import net.dv8tion.jda.api.EmbedBuilder;
55
import net.dv8tion.jda.api.JDA;
6+
import net.dv8tion.jda.api.Permission;
67
import net.dv8tion.jda.api.entities.Guild;
78
import net.dv8tion.jda.api.entities.MessageEmbed;
89
import net.dv8tion.jda.api.entities.NewsChannel;
@@ -20,6 +21,7 @@
2021

2122
import java.sql.SQLException;
2223
import java.time.OffsetDateTime;
24+
import java.util.Collections;
2325

2426
/**
2527
* Job which posts a new question to the QOTW channel.
@@ -44,6 +46,9 @@ protected void execute(JobExecutionContext context, JDA jda) throws JobExecution
4446
QOTWQuestion question = nextQuestion.get();
4547
QOTWConfig qotw = config.getQotw();
4648
qotw.getSubmissionChannel().getThreadChannels().forEach(thread -> thread.getManager().setArchived(true).queue());
49+
qotw.getSubmissionChannel().getManager()
50+
.putRolePermissionOverride(guild.getIdLong(), Collections.singleton(Permission.MESSAGE_SEND_IN_THREADS), Collections.emptySet())
51+
.queue();
4752
if (question.getQuestionNumber() == null) {
4853
question.setQuestionNumber(repo.getNextQuestionNumber());
4954
}

src/main/java/net/javadiscord/javabot/systems/qotw/submissions/SubmissionControlsManager.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,7 @@ public void sendControls() {
9090
Button.danger("qotw-submission:controls:decline", "Decline"),
9191
Button.secondary("qotw-submission:controls:delete", "🗑️")
9292
).queue();
93-
this.removeThreadOwner(thread.getJDA(), thread);
9493
log.info("Sent Submission Controls to thread {}", thread.getName());
95-
96-
}
97-
98-
private void removeThreadOwner(JDA jda, ThreadChannel thread) {
99-
DbHelper.doDaoAction(QOTWSubmissionRepository::new, dao -> {
100-
Optional<QOTWSubmission> submissionOptional = dao.getSubmissionByThreadId(thread.getIdLong());
101-
submissionOptional.ifPresent(submission -> jda.retrieveUserById(submission.getAuthorId()).queue(
102-
author -> thread.removeThreadMember(author).queue()
103-
));
104-
});
10594
}
10695

10796
/**

0 commit comments

Comments
 (0)