Skip to content

Commit f8c91a9

Browse files
authored
using a better method to retrieve start message for thread (#1106)
* using a better method to retrieve start message for thread * replace retrieveMessageById with getStartMessage on threadChannel channel type
1 parent f045ccf commit f8c91a9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ private static boolean isPostedBySelfUser(Message message) {
9797
}
9898

9999
private RestAction<Message> createAIResponse(ThreadChannel threadChannel) {
100-
RestAction<Message> originalQuestion =
101-
threadChannel.retrieveMessageById(threadChannel.getIdLong());
100+
RestAction<Message> originalQuestion = threadChannel.retrieveStartMessage();
102101
return originalQuestion.flatMap(HelpThreadCreatedListener::isContextSufficient,
103102
message -> helper.constructChatGptAttempt(threadChannel, getMessageContent(message),
104103
componentIdInteractor));
@@ -110,7 +109,7 @@ private static boolean isContextSufficient(Message message) {
110109
}
111110

112111
private RestAction<Void> pinOriginalQuestion(ThreadChannel threadChannel) {
113-
return threadChannel.retrieveMessageById(threadChannel.getIdLong()).flatMap(Message::pin);
112+
return threadChannel.retrieveStartMessage().flatMap(Message::pin);
114113
}
115114

116115
private RestAction<Message> generateAutomatedResponse(ThreadChannel threadChannel) {
@@ -172,7 +171,7 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
172171
ThreadChannel channel = event.getChannel().asThreadChannel();
173172
Member interactionUser = Objects.requireNonNull(event.getMember());
174173

175-
channel.retrieveMessageById(channel.getId())
174+
channel.retrieveStartMessage()
176175
.queue(forumPostMessage -> handleDismiss(interactionUser, channel, forumPostMessage,
177176
event, args));
178177

0 commit comments

Comments
 (0)