2020import net .dv8tion .jda .api .interactions .components .ActionRow ;
2121import net .dv8tion .jda .api .interactions .components .buttons .Button ;
2222import net .javadiscord .javabot .data .config .BotConfig ;
23- import net .javadiscord .javabot .data .config .GuildConfig ;
2423import net .javadiscord .javabot .data .config .guild .HelpConfig ;
2524import net .javadiscord .javabot .data .h2db .DbActions ;
26- import net .javadiscord .javabot .Bot ;
27- import net .javadiscord .javabot .data .config .guild .HelpConfig ;
2825import net .javadiscord .javabot .data .config .guild .HelpForumConfig ;
2926import net .javadiscord .javabot .systems .help .HelpChannelManager ;
3027import net .javadiscord .javabot .systems .help .HelpExperienceService ;
@@ -58,6 +55,7 @@ public class ForumHelpListener extends ListenerAdapter implements ButtonHandler
5855 private final DataSource dataSource ;
5956 private final HelpAccountRepository helpAccountRepository ;
6057 private final HelpTransactionRepository helpTransactionRepository ;
58+ private final UserPreferenceService userPreferenceService ;
6159 private final DbActions dbActions ;
6260
6361 @ Override
@@ -87,7 +85,7 @@ public void onChannelCreate(@NotNull ChannelCreateEvent event) {
8785 if (event .getGuild () == null || isInvalidForumPost (event .getChannel ())) {
8886 return ;
8987 }
90- HelpForumConfig config = Bot . getConfig () .get (event .getGuild ()).getHelpForumConfig ();
88+ HelpForumConfig config = botConfig .get (event .getGuild ()).getHelpForumConfig ();
9189 ThreadChannel post = event .getChannel ().asThreadChannel ();
9290 if (isInvalidHelpForumChannel (post .getParentChannel ().asForumChannel ())) {
9391 return ;
@@ -98,8 +96,7 @@ public void onChannelCreate(@NotNull ChannelCreateEvent event) {
9896 Button .secondary (ComponentIdBuilder .build (ForumHelpManager .HELP_GUIDELINES_IDENTIFIER ), "View Help Guidelines" )
9997 )).queue (success -> {
10098 // send /close reminder (if enabled)
101- UserPreferenceService service = new UserPreferenceService (Bot .getDataSource ());
102- UserPreference preference = service .getOrCreate (post .getOwnerIdLong (), Preference .FORUM_CLOSE_REMINDER );
99+ UserPreference preference = userPreferenceService .getOrCreate (post .getOwnerIdLong (), Preference .FORUM_CLOSE_REMINDER );
103100 if (Boolean .parseBoolean (preference .getState ())) {
104101 post .sendMessageFormat (config .getCloseReminderText (), UserSnowflake .fromId (post .getOwnerIdLong ()).getAsMention ()).queue ();
105102 }
@@ -115,9 +112,8 @@ public void handleButton(@NotNull ButtonInteractionEvent event, @NotNull Button
115112 Responses .error (event , "This button may only be used inside help forum threads." ).queue ();
116113 return ;
117114 }
118- ForumHelpManager manager = new ForumHelpManager (event .getChannel ().asThreadChannel (), dbActions , botConfig , dataSource , helpAccountRepository , helpTransactionRepository );
119115 ThreadChannel post = event .getChannel ().asThreadChannel ();
120- ForumHelpManager manager = new ForumHelpManager (post );
116+ ForumHelpManager manager = new ForumHelpManager (post , dbActions , botConfig , dataSource , helpAccountRepository , helpTransactionRepository );
121117 switch (id [0 ]) {
122118 case ForumHelpManager .HELP_THANKS_IDENTIFIER -> handleHelpThanksInteraction (event , manager , id );
123119 case ForumHelpManager .HELP_GUIDELINES_IDENTIFIER -> handleReplyGuidelines (event , post .getParentChannel ().asForumChannel ());
@@ -131,7 +127,7 @@ private boolean isInvalidForumPost(@NotNull Channel channel) {
131127 }
132128
133129 private boolean isInvalidHelpForumChannel (@ NotNull ForumChannel forum ) {
134- HelpForumConfig config = Bot . getConfig () .get (forum .getGuild ()).getHelpForumConfig ();
130+ HelpForumConfig config = botConfig .get (forum .getGuild ()).getHelpForumConfig ();
135131 return config .getHelpForumChannelId () != forum .getIdLong ();
136132 }
137133
@@ -178,7 +174,7 @@ private void handleReplyGuidelines(@NotNull IReplyCallback callback, @NotNull Fo
178174
179175 private void handlePostClose (ButtonInteractionEvent event , @ NotNull ForumHelpManager manager ) {
180176 if (manager .isForumEligibleToBeUnreserved (event )) {
181- manager .close (event , event .getUser ().getIdLong () == manager .postThread ().getOwnerIdLong (), null );
177+ manager .close (event , event .getUser ().getIdLong () == manager .getPostThread ().getOwnerIdLong (), null );
182178 } else {
183179 Responses .warning (event , "Could not close this post" , "You're not allowed to close this post." ).queue ();
184180 }
0 commit comments