Skip to content

Commit d007ec0

Browse files
Further Improve QOTW Submissions (#272)
Closes #271 This PR attempts to further improve the QOTW functionality, by only adding QOTW Reviewers once the Review Phase has started. This also fixes an issue regarding QOTW Notifications, which would always show the "Reasons" field, even if they were empty.
1 parent 4bfe87d commit d007ec0

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/main/java/net/javadiscord/javabot/systems/notification/QOTWNotificationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private MessageEmbed buildSubmissionActionEmbed(User author, ThreadChannel threa
145145
if (thread != null && status != SubmissionStatus.DELETED) {
146146
builder.addField("Thread", thread.getAsMention(), true);
147147
}
148-
if (reasons != null) {
148+
if (reasons != null && reasons.length > 0) {
149149
builder.addField("Reason(s)", String.join(", ", reasons), true);
150150
}
151151
return builder.build();

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
*/
2828
@Slf4j
2929
public class SubmissionControlsManager {
30-
private final String SUBMISSION_ACCEPTED = "\u2705";
31-
private final String SUBMISSION_DECLINED = "\u274C";
32-
private final String SUBMISSION_PENDING = "\uD83D\uDD52";
30+
private static final String SUBMISSION_ACCEPTED = "\u2705";
31+
private static final String SUBMISSION_DECLINED = "\u274C";
32+
private static final String SUBMISSION_PENDING = "\uD83D\uDD52";
3333

3434
private final Guild guild;
3535
private final QOTWConfig config;
@@ -77,6 +77,13 @@ public SubmissionControlsManager(Guild guild, ThreadChannel channel) {
7777
public void sendControls() {
7878
ThreadChannel thread = this.guild.getThreadChannelById(this.submission.getThreadId());
7979
if (thread == null) return;
80+
// The Thread's starting message
81+
if (thread.getMessageCount() <= 1) {
82+
new QOTWNotificationService(guild)
83+
.sendSubmissionActionNotification(guild.getJDA().getSelfUser(), thread, SubmissionStatus.DELETED, "Empty Submission");
84+
thread.delete().queue();
85+
return;
86+
}
8087
thread.getManager().setName(String.format("%s %s", SUBMISSION_PENDING, thread.getName())).queue();
8188
thread.sendMessage(config.getQOTWReviewRole().getAsMention())
8289
.setEmbeds(new EmbedBuilder()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public WebhookMessageAction<?> handleSubmission(ButtonInteractionEvent event, in
6464
DbHelper.doDaoAction(QuestionQueueRepository::new, dao -> {
6565
var questionOptional = dao.findByQuestionNumber(questionNumber);
6666
if (questionOptional.isPresent()) {
67-
thread.sendMessage(String.format("%s %s", config.getQOTWReviewRole(), member.getAsMention()))
67+
thread.sendMessage(member.getAsMention())
6868
.setEmbeds(buildSubmissionThreadEmbed(event.getUser(), questionOptional.get(), config))
6969
.setActionRows(ActionRow.of(Button.danger("qotw-submission:delete", "Delete Submission")))
7070
.queue();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public InteractionCallbackAction<InteractionHook> handleSlashCommandInteraction(
5555
}
5656
QOTWSubmission submission = submissionOptional.get();
5757
if (submission.getStatus() != SubmissionStatus.ACCEPTED) {
58-
Responses.error(event.getHook(), String.format("Submission must be reviewed and accepted!", threadId)).queue();
58+
Responses.error(event.getHook(), "The Submission must be reviewed and accepted!").queue();
5959
return;
6060
}
6161
if (config.getQotw().getQuestionChannel().getThreadChannels().stream().anyMatch(thread -> thread.getName().equals(submissionThread.getName()))) {
62-
Responses.error(event.getHook(), String.format("Submission was already marked as the best answer.", threadId)).queue();
62+
Responses.error(event.getHook(), "The Submission was already marked as one of the best answers.").queue();
6363
return;
6464
}
6565
List<Message> messages = this.getSubmissionContent(submissionThread);
@@ -98,7 +98,7 @@ private MessageEmbed buildBestAnswerEmbed(Member member) {
9898
.setAuthor(member.getUser().getAsTag(), null, member.getEffectiveAvatarUrl())
9999
.setTitle("Best Answer")
100100
.setColor(Bot.config.get(member.getGuild()).getSlashCommand().getDefaultColor())
101-
.setDescription(String.format("%s's submission was marked as the **best answer.**", member.getAsMention()))
101+
.setDescription(String.format("%s's submission was marked as one of the **best answers** (+1 QOTW-Point)", member.getAsMention()))
102102
.build();
103103
}
104104

0 commit comments

Comments
 (0)