Skip to content

Commit c079e3f

Browse files
Implement suggested whitespace changes
Co-authored-by: Dynxsty <jasonlessenich@gmail.com>
1 parent 52af4c0 commit c079e3f

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/main/java/net/javadiscord/javabot/systems/qotw/commands/view/QOTWListAnswersSubcommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public void execute(SlashCommandInteractionEvent event) {
4545
DbActions.doAsyncDaoAction(QOTWSubmissionRepository::new, repo -> {
4646
List<QOTWSubmission> submissions = repo.getSubmissionsByQuestionNumber(event.getGuild().getIdLong(), questionNum);
4747
EmbedBuilder eb = new EmbedBuilder();
48-
eb.setDescription("**answers of Question of the week #"+questionNum+"**\n");
48+
eb.setDescription("**Answers of Question of the Week #" + questionNum + "**\n");
4949
TextChannel submissionChannel = Bot.getConfig().get(event.getGuild()).getQotwConfig().getSubmissionChannel();
5050
String allAnswers = submissions
5151
.stream()
5252
.filter(submission -> isSubmissionVisible(submission, event.getUser().getIdLong()))
5353
.filter(submission -> submission.getQuestionNumber() == questionNum)
5454
.map(s -> (isBestAnswer(submissionChannel,s) ?
55-
"best " : s.getStatus() == SubmissionStatus.ACCEPTED?"accepted ":"")+
56-
"Answer by <@"+s.getAuthorId()+">")
55+
"best " : s.getStatus() == SubmissionStatus.ACCEPTED ? "accepted " : "")+
56+
"Answer by <@" + s.getAuthorId() + ">")
5757
.collect(Collectors.joining("\n"));
5858
if (allAnswers.isEmpty()) {
5959
allAnswers = "No accepted answers found.";

src/main/java/net/javadiscord/javabot/systems/qotw/commands/view/QOTWQuerySubcommand.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class QOTWQuerySubcommand extends SlashCommand.Subcommand implements Butt
4141
public QOTWQuerySubcommand() {
4242
setSubcommandData(new SubcommandData("list-questions", "Lists previous questions of the week")
4343
.addOption(OptionType.STRING, "query", "Only queries questions that contain a specific query", false)
44-
.addOption(OptionType.INTEGER, "page", "The page to show, starting with 1"));
44+
.addOption(OptionType.INTEGER, "page", "The page to show, starting with 1", false));
4545
}
4646

4747
@Override
@@ -50,14 +50,14 @@ public void execute(SlashCommandInteractionEvent event) {
5050
Responses.replyGuildOnly(event).setEphemeral(true).queue();
5151
return;
5252
}
53-
String query = event.getOption("query", ()->"", OptionMapping::getAsString);
54-
int page = event.getOption("page",() -> 1, OptionMapping::getAsInt)-1;
53+
String query = event.getOption("query", "", OptionMapping::getAsString);
54+
int page = event.getOption("page", 1, OptionMapping::getAsInt) -1;
5555
if (page < 0) {
5656
Responses.error(event, "Invalid page - must be >= 1").queue();
5757
return;
5858
}
5959
event.deferReply(true).queue();
60-
DbActions.doAsyncDaoAction(QuestionQueueRepository::new, repo->{
60+
DbActions.doAsyncDaoAction(QuestionQueueRepository::new, repo-> {
6161
MessageEmbed embed = buildListQuestionsEmbed(repo, event.getGuild().getIdLong(), query, page);
6262
event.getHook()
6363
.sendMessageEmbeds(embed)
@@ -91,9 +91,9 @@ private ActionRow buildPageControls(String query, int page, MessageEmbed embed)
9191
query = query.substring(0,MAX_BUTTON_QUERY_LENGTH);
9292
}
9393
return ActionRow.of(
94-
Button.primary(ComponentIdBuilder.build("qotw-list-questions", page-1+"", query), "Previous Page")
94+
Button.primary(ComponentIdBuilder.build("qotw-list-questions", page - 1 + "", query), "Previous Page")
9595
.withDisabled(page <= 0),
96-
Button.primary(ComponentIdBuilder.build("qotw-list-questions", page+1+"", query), "Next Page")
96+
Button.primary(ComponentIdBuilder.build("qotw-list-questions", page + 1 + "", query), "Next Page")
9797
.withDisabled(embed.getFields().size() < PAGE_LIMIT)
9898
);
9999
}
@@ -113,7 +113,7 @@ private MessageEmbed buildListQuestionsEmbed(QuestionQueueRepository repo, long
113113
eb.appendDescription(" on this page");
114114
}
115115
}
116-
eb.setFooter("Page "+(page+1));
116+
eb.setFooter("Page " + (page+1));
117117
eb.setColor(Responses.Type.DEFAULT.getColor());
118118
return eb.build();
119119
}

src/main/java/net/javadiscord/javabot/systems/qotw/commands/view/QOTWViewAnswerSubcommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class QOTWViewAnswerSubcommand extends SlashCommand.Subcommand{
2525
* The constructor of this class, which sets the corresponding {@link SubcommandData}.
2626
*/
2727
public QOTWViewAnswerSubcommand() {
28-
setSubcommandData(new SubcommandData("answer", "Views the content of an answer to the Question of the week")
28+
setSubcommandData(new SubcommandData("answer", "Views the content of an answer to the Question of the Week")
2929
.addOption(OptionType.INTEGER, "question", "The question number the answer has been submitted to", true)
3030
.addOption(OptionType.USER, "answerer", "The user who answered the question", true));
3131
}
@@ -65,17 +65,17 @@ public void execute(SlashCommandInteractionEvent event) {
6565
buildQOTWInfoEmbed(submission, event.getMember()==null?event.getUser().getName():event.getMember().getEffectiveName()),
6666
"QOTW #"+submission.getQuestionNumber(),
6767
history.getRetrievedHistory(),
68-
()->Responses.success(event.getHook(), "View Answer", "Answer copied successfully").setEphemeral(true))),
69-
()->Responses.error(event.getHook(), "The QOTW submission thread was not found.").queue());
68+
() -> Responses.success(event.getHook(), "View Answer", "Answer copied successfully").setEphemeral(true))),
69+
() -> Responses.error(event.getHook(), "The QOTW submission thread was not found.").queue());
7070
});
7171
});
7272
}
7373

7474
private @NotNull MessageEmbed buildQOTWInfoEmbed(QOTWSubmission submission, String requester) {
7575
return new EmbedBuilder()
76-
.setTitle("Answer to Question of the Week #"+submission.getQuestionNumber())
77-
.setDescription("Answer by <@"+submission.getAuthorId()+">")
78-
.setFooter("Requested by "+requester)
76+
.setTitle("Answer to Question of the Week #" + submission.getQuestionNumber())
77+
.setDescription("Answer by <@" + submission.getAuthorId() + ">")
78+
.setFooter("Requested by " + requester)
7979
.setColor(Responses.Type.DEFAULT.getColor())
8080
.build();
8181
}

src/main/java/net/javadiscord/javabot/systems/qotw/dao/QuestionQueueRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public List<QOTWQuestion> getUsedQuestionsWithQuery(long guildId, String query,
135135
String sql = "SELECT * FROM qotw_question WHERE guild_id = ? AND \"text\" LIKE ? AND used = TRUE ORDER BY question_number DESC, created_at ASC LIMIT ? OFFSET ?";
136136
try (PreparedStatement stmt = con.prepareStatement(sql)) {
137137
stmt.setLong(1, guildId);
138-
stmt.setString(2, "%"+query.toLowerCase()+"%");
138+
stmt.setString(2, "%" + query.toLowerCase() + "%");
139139
stmt.setInt(3, size);
140140
stmt.setInt(4, page);
141141
ResultSet rs = stmt.executeQuery();

0 commit comments

Comments
 (0)