Skip to content

Commit 5298f31

Browse files
used embedbuilder chaining
1 parent 0553231 commit 5298f31

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static boolean isSubmissionVisible(@NotNull QOTWSubmission submission, lo
4646
@Override
4747
public void execute(@NotNull SlashCommandInteractionEvent event) {
4848
if (!event.isFromGuild()) {
49-
Responses.replyGuildOnly(event).setEphemeral(true).queue();
49+
Responses.replyGuildOnly(event).queue();
5050
return;
5151
}
5252
OptionMapping questionNumOption = event.getOption("question");

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ private ActionRow buildPageControls(@NotNull String query, int page, MessageEmbe
9898

9999
private @NotNull MessageEmbed buildListQuestionsEmbed(@NotNull QuestionQueueRepository repo, long guildId, String query, int page) throws SQLException {
100100
List<QOTWQuestion> questions = repo.getUsedQuestionsWithQuery(guildId, query, page * PAGE_LIMIT, PAGE_LIMIT);
101-
EmbedBuilder eb = new EmbedBuilder();
102-
eb.setDescription("**Questions of the Week" + (query.isEmpty() ? "" : " matching '" + query + "'") + "**");
103-
questions
104-
.stream()
101+
EmbedBuilder eb = new EmbedBuilder()
102+
.setDescription("**Questions of the Week" + (query.isEmpty() ? "" : " matching '" + query + "'") + "**")
103+
.setColor(Responses.Type.DEFAULT.getColor())
104+
.setFooter("Page " + (page + 1));
105+
questions.stream()
105106
.sorted(Comparator.comparingInt(QOTWQuestion::getQuestionNumber))
106107
.map(q -> new MessageEmbed.Field("Question #" + q.getQuestionNumber(), q.getText(), true))
107108
.forEach(eb::addField);
@@ -111,10 +112,6 @@ private ActionRow buildPageControls(@NotNull String query, int page, MessageEmbe
111112
eb.appendDescription(" on this page");
112113
}
113114
}
114-
eb.setFooter("Page " + (page + 1));
115-
eb.setColor(Responses.Type.DEFAULT.getColor());
116115
return eb.build();
117116
}
118-
119-
120117
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public QOTWViewAnswerSubcommand() {
3131
}
3232

3333
@Override
34-
public void execute(SlashCommandInteractionEvent event) {
34+
public void execute(@NotNull SlashCommandInteractionEvent event) {
3535
if (!event.isFromGuild()) {
3636
Responses.replyGuildOnly(event).setEphemeral(true).queue();
3737
return;
@@ -69,7 +69,7 @@ public void execute(SlashCommandInteractionEvent event) {
6969
});
7070
}
7171

72-
private @NotNull MessageEmbed buildQOTWInfoEmbed(QOTWSubmission submission, String requester) {
72+
private @NotNull MessageEmbed buildQOTWInfoEmbed(@NotNull QOTWSubmission submission, String requester) {
7373
return new EmbedBuilder()
7474
.setTitle("Answer to Question of the Week #" + submission.getQuestionNumber())
7575
.setDescription("Answer by <@" + submission.getAuthorId() + ">")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class QOTWViewCommand extends SlashCommand {
1616
public QOTWViewCommand() {
1717
setSlashCommandData(Commands.slash("qotw-view", "Query 'Questions of the Week' and their answers")
1818
.setDefaultPermissions(DefaultMemberPermissions.ENABLED)
19-
.setGuildOnly(true));
19+
.setGuildOnly(true)
20+
);
2021
addSubcommands(new QOTWQuerySubcommand(), new QOTWListAnswersSubcommand(), new QOTWViewAnswerSubcommand());
2122

2223
}

0 commit comments

Comments
 (0)