@@ -52,32 +52,26 @@ public void execute() throws SQLException {
5252 for (Guild guild : jda .getGuilds ()) {
5353 GuildConfig config = botConfig .get (guild );
5454 if (config .getModerationConfig ().getLogChannel () == null ) continue ;
55- try (Connection c = dataSource .getConnection ()) {
56- Optional <QOTWQuestion > nextQuestion = questionQueueRepository .getNextQuestion (guild .getIdLong ());
57- if (nextQuestion .isEmpty ()) {
58- notificationService .withGuild (guild ).sendToModerationLog (m -> m .sendMessageFormat ("Warning! %s No available next question for QOTW!" , config .getQotwConfig ().getQOTWReviewRole ().getAsMention ()));
59- } else {
60- QOTWQuestion question = nextQuestion .get ();
61- QOTWConfig qotw = config .getQotwConfig ();
62- qotw .getSubmissionChannel ().getThreadChannels ().forEach (thread -> thread .getManager ().setLocked (true ).setArchived (true ).queue ());
63- qotw .getSubmissionChannel ().getManager ()
64- .putRolePermissionOverride (guild .getIdLong (), Set .of (Permission .VIEW_CHANNEL , Permission .MESSAGE_SEND_IN_THREADS ), Collections .singleton (Permission .MESSAGE_SEND ))
65- .queue ();
66- if (question .getQuestionNumber () == null ) {
67- question .setQuestionNumber (questionQueueRepository .getNextQuestionNumber ());
68- }
69- NewsChannel questionChannel = qotw .getQuestionChannel ();
70- if (questionChannel == null ) continue ;
71- questionChannel .sendMessage (qotw .getQOTWRole ().getAsMention ())
72- .setEmbeds (this .buildQuestionEmbed (question ))
73- .setComponents (ActionRow .of (Button .success ("qotw-submission:submit:" + question .getQuestionNumber (), "Submit your Answer" )))
74- .queue (msg -> questionChannel .crosspostMessageById (msg .getIdLong ()).queue ());
75- questionQueueRepository .markUsed (question );
55+ Optional <QOTWQuestion > nextQuestion = questionQueueRepository .getNextQuestion (guild .getIdLong ());
56+ if (nextQuestion .isEmpty ()) {
57+ notificationService .withGuild (guild ).sendToModerationLog (m -> m .sendMessageFormat ("Warning! %s No available next question for QOTW!" , config .getQotwConfig ().getQOTWReviewRole ().getAsMention ()));
58+ } else {
59+ QOTWQuestion question = nextQuestion .get ();
60+ QOTWConfig qotw = config .getQotwConfig ();
61+ qotw .getSubmissionChannel ().getThreadChannels ().forEach (thread -> thread .getManager ().setLocked (true ).setArchived (true ).queue ());
62+ qotw .getSubmissionChannel ().getManager ()
63+ .putRolePermissionOverride (guild .getIdLong (), Set .of (Permission .VIEW_CHANNEL , Permission .MESSAGE_SEND_IN_THREADS ), Collections .singleton (Permission .MESSAGE_SEND ))
64+ .queue ();
65+ if (question .getQuestionNumber () == null ) {
66+ question .setQuestionNumber (questionQueueRepository .getNextQuestionNumber ());
7667 }
77- } catch (SQLException e ) {
78- ExceptionLogger .capture (e , getClass ().getSimpleName ());
79- notificationService .withGuild (guild ).sendToModerationLog (c -> c .sendMessageFormat ("Warning! %s Could not send next QOTW question:\n ```\n %s\n ```\n " , config .getQotwConfig ().getQOTWReviewRole ().getAsMention (), e .getMessage ()));
80- throw e ;
68+ NewsChannel questionChannel = qotw .getQuestionChannel ();
69+ if (questionChannel == null ) continue ;
70+ questionChannel .sendMessage (qotw .getQOTWRole ().getAsMention ())
71+ .setEmbeds (this .buildQuestionEmbed (question ))
72+ .setComponents (ActionRow .of (Button .success ("qotw-submission:submit:" + question .getQuestionNumber (), "Submit your Answer" )))
73+ .queue (msg -> questionChannel .crosspostMessageById (msg .getIdLong ()).queue ());
74+ questionQueueRepository .markUsed (question );
8175 }
8276 }
8377 }
0 commit comments