Skip to content

Commit eebbd59

Browse files
Added custom thank message & converted ForumHelpManager into a record
1 parent 0872a02 commit eebbd59

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/main/java/net/javadiscord/javabot/systems/help/forum/ForumHelpListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void handleButton(@NotNull ButtonInteractionEvent event, @NotNull Button
7878
}
7979

8080
private void handleHelpThanksInteraction(@NotNull ButtonInteractionEvent event, @NotNull ForumHelpManager manager, String @NotNull [] id) {
81-
ThreadChannel post = manager.getPostThread();
81+
ThreadChannel post = manager.postThread();
8282
HelpConfig config = Bot.getConfig().get(event.getGuild()).getHelpConfig();
8383
switch (id[2]) {
8484
case "done" -> {

src/main/java/net/javadiscord/javabot/systems/help/forum/ForumHelpManager.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.javadiscord.javabot.systems.help.forum;
22

33
import com.dynxsty.dih4jda.interactions.ComponentIdBuilder;
4-
import lombok.RequiredArgsConstructor;
54
import net.dv8tion.jda.api.entities.Member;
65
import net.dv8tion.jda.api.entities.Message;
76
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
@@ -15,7 +14,6 @@
1514
import net.javadiscord.javabot.Bot;
1615
import net.javadiscord.javabot.data.config.guild.HelpConfig;
1716
import net.javadiscord.javabot.data.h2db.DbActions;
18-
import net.javadiscord.javabot.systems.help.HelpChannelManager;
1917
import net.javadiscord.javabot.systems.help.HelpExperienceService;
2018
import net.javadiscord.javabot.systems.help.model.HelpTransactionMessage;
2119
import net.javadiscord.javabot.util.ExceptionLogger;
@@ -30,21 +28,26 @@
3028

3129
/**
3230
* Manages all interactions regarding the help forum system.
31+
*
32+
* @param postThread The posts' {@link ThreadChannel}.
3333
*/
34-
@RequiredArgsConstructor
35-
public class ForumHelpManager {
34+
public record ForumHelpManager(ThreadChannel postThread) {
35+
/**
36+
* Static String that contains the Thank Message Text.
37+
*/
38+
public static final String THANK_MESSAGE_TEXT = "Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click **I'm done here. Close this post!**.";
39+
3640
/**
3741
* The identifier used for all help thanks-related buttons.
3842
*/
3943
public static final String HELP_THANKS_IDENTIFIER = "forum-help-thank";
40-
private final ThreadChannel postThread;
4144

4245
/**
4346
* Builds and replies {@link ActionRow}s with all members which helped the
4447
* owner of the {@link ForumHelpManager#postThread} forum post.
4548
*
4649
* @param callback The callback to reply to.
47-
* @param helpers The list of helpers to thank.
50+
* @param helpers The list of helpers to thank.
4851
* @return The {@link ReplyCallbackAction}.
4952
*/
5053
public ReplyCallbackAction replyHelpThanks(IReplyCallback callback, @NotNull List<Member> helpers) {
@@ -61,7 +64,7 @@ public ReplyCallbackAction replyHelpThanks(IReplyCallback callback, @NotNull Lis
6164
List<ActionRow> rows = new ArrayList<>();
6265
rows.add(controlsRow);
6366
rows.addAll(MessageActionUtils.toActionRows(helperThanksButtons));
64-
return callback.reply(HelpChannelManager.THANK_MESSAGE_TEXT)
67+
return callback.reply(THANK_MESSAGE_TEXT)
6568
.setComponents(rows);
6669
}
6770

@@ -86,9 +89,9 @@ public void close(IReplyCallback callback, boolean withHelpers, @Nullable String
8689
/**
8790
* Thanks a single user.
8891
*
89-
* @param event The {@link ButtonInteractionEvent} that was fired.
92+
* @param event The {@link ButtonInteractionEvent} that was fired.
9093
* @param postThread The {@link ThreadChannel} post.
91-
* @param helperId The helpers' discord id.
94+
* @param helperId The helpers' discord id.
9295
*/
9396
public void thankHelper(@NotNull ButtonInteractionEvent event, ThreadChannel postThread, long helperId) {
9497
event.getJDA().retrieveUserById(helperId).queue(helper -> {
@@ -119,9 +122,6 @@ public void thankHelper(@NotNull ButtonInteractionEvent event, ThreadChannel pos
119122
});
120123
}
121124

122-
public ThreadChannel getPostThread() {
123-
return postThread;
124-
}
125125

126126
private @NotNull List<Member> getPostHelpers() {
127127
List<Member> helpers = new ArrayList<>(20);

0 commit comments

Comments
 (0)