Skip to content

Commit 47a2f74

Browse files
authored
Merge pull request #404 from danthe1st/fix-qotw-reviewedby-log
make QOTW review log show reviewer in reviewer field
2 parents 9e5988e + 3d0829b commit 47a2f74

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public void handleSelectReview(StringSelectInteractionEvent event, String thread
129129
final QOTWSubmission submission = new QOTWSubmission(submissionThread);
130130
submission.retrieveAuthor(author -> {
131131
switch (status) {
132-
case ACCEPT_BEST -> acceptSubmission(submissionThread, author, true);
133-
case ACCEPT -> acceptSubmission(submissionThread, author, false);
134-
default -> declineSubmission(submissionThread, author, status);
132+
case ACCEPT_BEST -> acceptSubmission(submissionThread, author, event.getMember(), true);
133+
case ACCEPT -> acceptSubmission(submissionThread, author, event.getMember(), false);
134+
default -> declineSubmission(submissionThread, author, event.getMember(), status);
135135
}
136136
if (config.getSubmissionChannel().getThreadChannels().size() <= 1) {
137137
Optional<ThreadChannel> newestPostOptional = config.getSubmissionsForumChannel().getThreadChannels()
@@ -185,17 +185,18 @@ private boolean canCreateSubmissions(Member member) {
185185
*
186186
* @param thread The submission's {@link ThreadChannel}.
187187
* @param author The submissions' author.
188+
* @param reviewedBy The reviewer.
188189
* @param bestAnswer Whether the submission is among the best answers for this week.
189190
*/
190-
public void acceptSubmission(@NotNull ThreadChannel thread, @NotNull User author, boolean bestAnswer) {
191+
public void acceptSubmission(@NotNull ThreadChannel thread, @NotNull User author, Member reviewedBy, boolean bestAnswer) {
191192
thread.getManager().setName(SUBMISSION_ACCEPTED + thread.getName().substring(1)).queue();
192193
pointsService.increment(author.getIdLong());
193194
notificationService.withQOTW(thread.getGuild(), author).sendAccountIncrementedNotification();
194195
if (bestAnswer) {
195196
pointsService.increment(author.getIdLong());
196197
notificationService.withQOTW(thread.getGuild(), author).sendBestAnswerNotification();
197198
}
198-
notificationService.withQOTW(thread.getGuild()).sendSubmissionActionNotification(author, new QOTWSubmission(thread), bestAnswer ? SubmissionStatus.ACCEPT_BEST : SubmissionStatus.ACCEPT);
199+
notificationService.withQOTW(thread.getGuild()).sendSubmissionActionNotification(reviewedBy.getUser(), new QOTWSubmission(thread), bestAnswer ? SubmissionStatus.ACCEPT_BEST : SubmissionStatus.ACCEPT);
199200
Optional<ThreadChannel> newestPostOptional = config.getSubmissionsForumChannel().getThreadChannels()
200201
.stream().max(Comparator.comparing(ThreadChannel::getTimeCreated));
201202
if (newestPostOptional.isPresent()) {
@@ -225,12 +226,13 @@ public void acceptSubmission(@NotNull ThreadChannel thread, @NotNull User author
225226
*
226227
* @param thread The submission's {@link ThreadChannel}.
227228
* @param author The submissions' author.
229+
* @param reviewedBy The reviewer
228230
* @param status The {@link SubmissionStatus}.
229231
*/
230-
public void declineSubmission(@NotNull ThreadChannel thread, User author, SubmissionStatus status) {
232+
public void declineSubmission(@NotNull ThreadChannel thread, User author, Member reviewedBy, SubmissionStatus status) {
231233
thread.getManager().setName(SUBMISSION_DECLINED + thread.getName().substring(1)).queue();
232234
notificationService.withQOTW(thread.getGuild(), author).sendSubmissionDeclinedEmbed(status);
233-
notificationService.withQOTW(thread.getGuild()).sendSubmissionActionNotification(author, new QOTWSubmission(thread), status);
235+
notificationService.withQOTW(thread.getGuild()).sendSubmissionActionNotification(reviewedBy.getUser(), new QOTWSubmission(thread), status);
234236
thread.getManager().setLocked(true).setArchived(true).queue();
235237
}
236238

src/main/java/net/javadiscord/javabot/systems/qotw/submissions/subcommands/QOTWReviewSubcommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
8181
submission.retrieveAuthor(author -> {
8282
SubmissionManager manager = new SubmissionManager(qotwConfig, pointsService, questionQueueRepository, notificationService, asyncPool);
8383
if (state.contains("ACCEPT")) {
84-
manager.acceptSubmission(submissionThread, author, state.equals("ACCEPT_BEST"));
84+
manager.acceptSubmission(submissionThread, author, event.getMember(), state.equals("ACCEPT_BEST"));
8585
Responses.success(event.getHook(), "Submission Accepted", "Successfully accepted submission by " + author.getAsMention()).queue();
8686
} else {
8787
// just do a "wrong answer" for now. this command is going to be removed
8888
// in the near future anyway
89-
manager.declineSubmission(submissionThread, author, SubmissionStatus.DECLINE_WRONG_ANSWER);
89+
manager.declineSubmission(submissionThread, author, event.getMember(), SubmissionStatus.DECLINE_WRONG_ANSWER);
9090
Responses.success(event.getHook(), "Submission Declined", "Successfully declined submission by " + author.getAsMention()).queue();
9191
}
9292
if (qotwConfig.getSubmissionChannel().getThreadChannels().size() <= 1) {

0 commit comments

Comments
 (0)