Skip to content

Commit 8044d71

Browse files
Resolved remaining errors
1 parent a6fffe7 commit 8044d71

File tree

11 files changed

+103
-401
lines changed

11 files changed

+103
-401
lines changed

src/main/java/net/javadiscord/javabot/data/config/guild/QOTWConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import lombok.Data;
44
import lombok.EqualsAndHashCode;
55
import net.dv8tion.jda.api.entities.Role;
6+
import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
67
import net.dv8tion.jda.api.entities.channel.concrete.NewsChannel;
78
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
89
import net.javadiscord.javabot.data.config.GuildConfigItem;
@@ -15,6 +16,7 @@
1516
public class QOTWConfig extends GuildConfigItem {
1617
private long questionChannelId;
1718
private long submissionChannelId;
19+
private long submissionsForumChannelId;
1820
private long questionRoleId;
1921
private long qotwReviewRoleId;
2022

@@ -26,6 +28,10 @@ public TextChannel getSubmissionChannel() {
2628
return this.getGuild().getTextChannelById(this.submissionChannelId);
2729
}
2830

31+
public ForumChannel getSubmissionsForumChannel() {
32+
return this.getGuild().getForumChannelById(this.submissionsForumChannelId);
33+
}
34+
2935
public Role getQOTWRole() {
3036
return this.getGuild().getRoleById(this.questionRoleId);
3137
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.jetbrains.annotations.NotNull;
1313
import org.springframework.stereotype.Service;
1414

15-
import java.util.concurrent.ExecutorService;
1615
import java.util.function.Function;
1716

1817
/**
@@ -23,7 +22,6 @@
2322
public class NotificationService {
2423
private final QOTWPointsService qotwPointsService;
2524
private final BotConfig botConfig;
26-
private final ExecutorService asyncPool;
2725

2826
@Contract("_ -> new")
2927
public @NotNull GuildNotificationService withGuild(Guild guild) {
@@ -40,7 +38,7 @@ public class NotificationService {
4038
}
4139

4240
public @NotNull QOTWNotificationService withQOTW(Guild guild, User user) {
43-
return new QOTWNotificationService(this, qotwPointsService, user, guild, botConfig.getSystems(), asyncPool);
41+
return new QOTWNotificationService(this, qotwPointsService, user, guild, botConfig.getSystems());
4442
}
4543

4644
/**

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.dv8tion.jda.api.entities.MessageEmbed;
99
import net.dv8tion.jda.api.entities.User;
1010
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
11+
import net.javadiscord.javabot.systems.qotw.model.QOTWSubmission;
1112
import net.javadiscord.javabot.systems.qotw.submissions.SubmissionStatus;
1213

1314
import org.jetbrains.annotations.NotNull;
@@ -30,13 +31,14 @@ public class QOTWGuildNotificationService {
3031
* Sends the executed action, performed on a QOTW submission thread, to the {@link Guild}s log channel.
3132
*
3233
* @param reviewedBy The user which reviewed the QOTW submission thread.
33-
* @param author The submissions' author.
34-
* @param submissionThread The submission thread itself.
34+
* @param submission The {@link QOTWSubmission}.
3535
* @param status The {@link SubmissionStatus}.
3636
*/
37-
public void sendSubmissionActionNotification(User reviewedBy, User author, ThreadChannel submissionThread, SubmissionStatus status) {
38-
notificationService.withGuild(guild).sendToModerationLog(c -> c.sendMessageEmbeds(buildSubmissionActionEmbed(author, submissionThread, reviewedBy, status)));
39-
log.info("{} {} {}'s QOTW Submission", reviewedBy.getAsTag(), status.name().toLowerCase(), author.getAsTag());
37+
public void sendSubmissionActionNotification(User reviewedBy, QOTWSubmission submission, SubmissionStatus status) {
38+
submission.retrieveAuthor(author -> {
39+
notificationService.withGuild(guild).sendToModerationLog(c -> c.sendMessageEmbeds(buildSubmissionActionEmbed(author, submission.getThread(), reviewedBy, status)));
40+
log.info("{} {} {}'s QOTW Submission", reviewedBy.getAsTag(), status.name().toLowerCase(), author.getAsTag());
41+
});
4042
}
4143

4244
private @NotNull MessageEmbed buildSubmissionActionEmbed(@NotNull User author, ThreadChannel thread, @NotNull User reviewedBy, @NotNull SubmissionStatus status) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public final class QOTWNotificationService extends QOTWGuildNotificationService
2727
private final QOTWAccount account;
2828
private final SystemsConfig systemsConfig;
2929

30-
QOTWNotificationService(NotificationService notificationService, QOTWPointsService pointsService,@NotNull User user, Guild guild, SystemsConfig systemsConfig, ExecutorService asyncPool) {
31-
super(notificationService, guild, asyncPool);
30+
QOTWNotificationService(NotificationService notificationService, QOTWPointsService pointsService,@NotNull User user, Guild guild, SystemsConfig systemsConfig) {
31+
super(notificationService, guild);
3232
this.user = user;
3333
this.guild = guild;
3434
QOTWAccount account;

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import net.dv8tion.jda.api.JDA;
44
import net.dv8tion.jda.api.entities.Guild;
55
import net.javadiscord.javabot.data.config.BotConfig;
6-
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
76
import net.javadiscord.javabot.data.config.guild.QOTWConfig;
8-
import net.javadiscord.javabot.data.h2db.DbHelper;
7+
import net.javadiscord.javabot.systems.notification.NotificationService;
98
import net.javadiscord.javabot.systems.qotw.dao.QuestionQueueRepository;
9+
import net.javadiscord.javabot.systems.qotw.model.QOTWSubmission;
1010
import net.javadiscord.javabot.systems.qotw.submissions.SubmissionManager;
1111
import net.javadiscord.javabot.systems.user_preferences.UserPreferenceService;
1212
import net.javadiscord.javabot.systems.user_preferences.model.Preference;
@@ -29,8 +29,8 @@ public class QOTWUserReminderJob {
2929
private final JDA jda;
3030
private final UserPreferenceService userPreferenceService;
3131
private final BotConfig botConfig;
32-
private final DbHelper dbHelper;
33-
private final QOTWSubmissionRepository qotwSubmissionRepository;
32+
private final QOTWPointsService pointsService;
33+
private final NotificationService notificationService;
3434
private final QuestionQueueRepository questionQueueRepository;
3535
private final ExecutorService asyncPool;
3636

@@ -41,17 +41,13 @@ public class QOTWUserReminderJob {
4141
public void execute() {
4242
for (Guild guild : jda.getGuilds()) {
4343
QOTWConfig config = botConfig.get(guild).getQotwConfig();
44-
List<QOTWSubmission> submissions = new SubmissionManager(config, dbHelper, qotwSubmissionRepository, questionQueueRepository, asyncPool).getActiveSubmissionThreads(guild.getIdLong());
44+
List<QOTWSubmission> submissions = new SubmissionManager(config, pointsService, questionQueueRepository, notificationService, asyncPool).getActiveSubmissions();
4545
for (QOTWSubmission submission : submissions) {
46-
UserPreference preference = userPreferenceService.getOrCreate(submission.getAuthorId(), Preference.QOTW_REMINDER);
47-
if (Boolean.parseBoolean(preference.getState())) {
48-
TextChannel channel = config.getSubmissionChannel();
49-
channel.getThreadChannels().stream().filter(t -> t.getIdLong() == submission.getThreadId()).forEach(t -> {
50-
if (t.getMessageCount() <= 1) {
51-
t.sendMessageFormat("**Question of the Week Reminder**\nHey <@%s>! You still have some time left to submit your answer!", submission.getAuthorId())
52-
.queue();
53-
}
54-
});
46+
UserPreference preference = userPreferenceService.getOrCreate(submission.getAuthor().getIdLong(), Preference.QOTW_REMINDER);
47+
if (Boolean.parseBoolean(preference.getState()) && submission.getThread().getMessageCount() <= 1) {
48+
submission.getThread()
49+
.sendMessageFormat("**Question of the Week Reminder**\nHey %s! You still have some time left to submit your answer!", submission.getAuthor().getAsMention())
50+
.queue();
5551
}
5652
}
5753
}

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

Lines changed: 0 additions & 102 deletions
This file was deleted.

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

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)