1010import net .javadiscord .javabot .data .config .BotConfig ;
1111import net .javadiscord .javabot .data .config .GuildConfig ;
1212import net .javadiscord .javabot .data .config .guild .QOTWConfig ;
13- import net .javadiscord .javabot .data .h2db .DbHelper ;
1413import net .javadiscord .javabot .systems .notification .NotificationService ;
1514import net .javadiscord .javabot .systems .qotw .submissions .SubmissionControlsManager ;
1615import net .javadiscord .javabot .systems .qotw .submissions .dao .QOTWSubmissionRepository ;
1716import net .javadiscord .javabot .systems .qotw .submissions .model .QOTWSubmission ;
18- import net .javadiscord .javabot .util .ExceptionLogger ;
1917import org .springframework .scheduling .annotation .Scheduled ;
2018import org .springframework .stereotype .Service ;
2119
2220import lombok .RequiredArgsConstructor ;
2321
24- import java .sql .Connection ;
2522import java .sql .SQLException ;
2623import java .util .Collections ;
2724import java .util .List ;
@@ -37,7 +34,6 @@ public class QOTWCloseSubmissionsJob {
3734 private final QOTWPointsService pointsService ;
3835 private final NotificationService notificationService ;
3936 private final BotConfig botConfig ;
40- private final DbHelper dbHelper ;
4137 private final QOTWSubmissionRepository qotwSubmissionRepository ;
4238
4339 /**
@@ -59,14 +55,9 @@ public void execute() throws SQLException {
5955 if (message == null ) continue ;
6056 message .editMessageComponents (ActionRow .of (Button .secondary ("qotw-submission:closed" , "Submissions closed" ).asDisabled ())).queue ();
6157 for (ThreadChannel thread : qotwConfig .getSubmissionChannel ().getThreadChannels ()) {
62- try (Connection con = dbHelper .getDataSource ().getConnection ()) {
63- Optional <QOTWSubmission > optionalSubmission = qotwSubmissionRepository .getSubmissionByThreadId (thread .getIdLong ());
64- if (optionalSubmission .isEmpty ()) continue ;
65- new SubmissionControlsManager (botConfig .get (guild ), optionalSubmission .get (), pointsService , notificationService ).sendControls ();
66- } catch (SQLException e ) {
67- ExceptionLogger .capture (e , getClass ().getSimpleName ());
68- throw e ;
69- }
58+ Optional <QOTWSubmission > optionalSubmission = qotwSubmissionRepository .getSubmissionByThreadId (thread .getIdLong ());
59+ if (optionalSubmission .isEmpty ()) continue ;
60+ new SubmissionControlsManager (botConfig .get (guild ), optionalSubmission .get (), pointsService , notificationService ).sendControls ();
7061 }
7162 }
7263 }
0 commit comments