1010import net .dv8tion .jda .api .entities .User ;
1111import net .dv8tion .jda .api .entities .channel .ChannelType ;
1212import net .dv8tion .jda .api .entities .channel .concrete .ThreadChannel ;
13+ import net .dv8tion .jda .api .entities .channel .unions .MessageChannelUnion ;
1314import net .dv8tion .jda .api .events .interaction .component .ButtonInteractionEvent ;
1415import net .dv8tion .jda .api .events .interaction .component .StringSelectInteractionEvent ;
15- import net .dv8tion .jda .api .interactions .InteractionHook ;
1616import net .dv8tion .jda .api .interactions .components .ActionRow ;
1717import net .dv8tion .jda .api .interactions .components .buttons .Button ;
1818import net .dv8tion .jda .api .requests .restaction .WebhookMessageCreateAction ;
@@ -125,24 +125,31 @@ public void handleSelectReview(StringSelectInteractionEvent event, String thread
125125 return ;
126126 }
127127 final SubmissionStatus status = SubmissionStatus .valueOf (event .getValues ().get (0 ));
128- event .deferReply ().queue ();
128+ event .deferEdit ().queue ();
129129 final QOTWSubmission submission = new QOTWSubmission (submissionThread );
130130 submission .retrieveAuthor (author -> {
131131 switch (status ) {
132- case ACCEPT_BEST -> acceptSubmission (event . getHook (), submissionThread , author , true );
133- case ACCEPT -> acceptSubmission (event . getHook (), submissionThread , author , false );
134- default -> declineSubmission (event . getHook (), submissionThread , author , status );
132+ case ACCEPT_BEST -> acceptSubmission (submissionThread , author , true );
133+ case ACCEPT -> acceptSubmission (submissionThread , author , false );
134+ default -> declineSubmission (submissionThread , author , status );
135135 }
136136 if (config .getSubmissionChannel ().getThreadChannels ().size () <= 1 ) {
137137 Optional <ThreadChannel > newestPostOptional = config .getSubmissionsForumChannel ().getThreadChannels ()
138138 .stream ().max (Comparator .comparing (ThreadChannel ::getTimeCreated ));
139139 newestPostOptional .ifPresent (p -> {
140140 p .getManager ().setAppliedTags ().queue ();
141- notificationService .withGuild (config .getGuild ()).sendToModerationLog (log -> log .sendMessageFormat ("All submissions have been reviewed!" ));
141+ MessageChannelUnion channel = event
142+ .getChannel ();
143+ channel
144+ .sendMessageFormat ("All submissions have been reviewed!" )
145+ .queue (msg -> {
146+ if (channel .getType ().isThread ()) {
147+ channel .asThreadChannel ().getManager ().setLocked (true ).queue ();
148+ }
149+ });
142150 });
143151 }
144- event .getMessage ().editMessageComponents (ActionRow .of (Button .secondary ("dummy" , "%s by %s" .formatted (status .getVerb (), event .getUser ().getAsTag ())).asDisabled ())).queue ();
145- Responses .info (event , "Review done!" , "Successfully reviewed %s! (`%s`)" , submissionThread .getAsMention (), status ).queue ();
152+ event .getHook ().editOriginalComponents (ActionRow .of (Button .secondary ("dummy" , "%s by %s" .formatted (status .getVerb (), event .getUser ().getAsTag ())).asDisabled ())).queue ();
146153 });
147154 }
148155
@@ -172,21 +179,18 @@ private boolean canCreateSubmissions(Member member) {
172179 /**
173180 * Accepts a submission.
174181 *
175- * @param hook The {@link net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent} that was fired.
176182 * @param thread The submission's {@link ThreadChannel}.
177183 * @param author The submissions' author.
178184 * @param bestAnswer Whether the submission is among the best answers for this week.
179185 */
180- public void acceptSubmission (InteractionHook hook , @ NotNull ThreadChannel thread , @ NotNull User author , boolean bestAnswer ) {
186+ public void acceptSubmission (@ NotNull ThreadChannel thread , @ NotNull User author , boolean bestAnswer ) {
181187 thread .getManager ().setName (SUBMISSION_ACCEPTED + thread .getName ().substring (1 )).queue ();
182188 pointsService .increment (author .getIdLong ());
183189 notificationService .withQOTW (thread .getGuild (), author ).sendAccountIncrementedNotification ();
184190 if (bestAnswer ) {
185191 pointsService .increment (author .getIdLong ());
186192 notificationService .withQOTW (thread .getGuild (), author ).sendBestAnswerNotification ();
187193 }
188- Responses .success (hook , "Submission Accepted" ,
189- "Successfully accepted submission by " + author .getAsMention ()).queue ();
190194 notificationService .withQOTW (thread .getGuild ()).sendSubmissionActionNotification (author , new QOTWSubmission (thread ), bestAnswer ? SubmissionStatus .ACCEPT_BEST : SubmissionStatus .ACCEPT );
191195 Optional <ThreadChannel > newestPostOptional = config .getSubmissionsForumChannel ().getThreadChannels ()
192196 .stream ().max (Comparator .comparing (ThreadChannel ::getTimeCreated ));
@@ -212,15 +216,13 @@ public void acceptSubmission(InteractionHook hook, @NotNull ThreadChannel thread
212216 /**
213217 * Declines a submission.
214218 *
215- * @param hook The {@link net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent} that was fired.
216219 * @param thread The submission's {@link ThreadChannel}.
217220 * @param author The submissions' author.
218221 * @param status The {@link SubmissionStatus}.
219222 */
220- public void declineSubmission (InteractionHook hook , @ NotNull ThreadChannel thread , User author , SubmissionStatus status ) {
223+ public void declineSubmission (@ NotNull ThreadChannel thread , User author , SubmissionStatus status ) {
221224 thread .getManager ().setName (SUBMISSION_DECLINED + thread .getName ().substring (1 )).queue ();
222225 notificationService .withQOTW (thread .getGuild (), author ).sendSubmissionDeclinedEmbed (status );
223- Responses .success (hook , "Submission Declined" , "Successfully declined submission by " + author .getAsMention ()).queue ();
224226 notificationService .withQOTW (thread .getGuild ()).sendSubmissionActionNotification (author , new QOTWSubmission (thread ), status );
225227 thread .getManager ().setLocked (true ).setArchived (true ).queue ();
226228 }
0 commit comments