diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java index 8e5db87dc0..19516dc347 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java @@ -4,6 +4,7 @@ import com.github.benmanes.caffeine.cache.Caffeine; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; @@ -25,6 +26,7 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * Listens for new help threads being created. That is, a user posted a question in the help forum. @@ -92,7 +94,7 @@ private RestAction createAIResponse(ThreadChannel threadChannel) { RestAction originalQuestion = threadChannel.retrieveMessageById(threadChannel.getIdLong()); return originalQuestion.flatMap(message -> helper.constructChatGptAttempt(threadChannel, - message.getContentRaw(), componentIdInteractor)); + getMessageContent(message), componentIdInteractor)); } private RestAction pinOriginalQuestion(ThreadChannel threadChannel) { @@ -126,6 +128,17 @@ private RestAction sendHelperHeadsUp(ThreadChannel threadChannel) { .flatMap(message -> message.editMessage(headsUpWithRole)); } + private String getMessageContent(Message message) { + if (message.getEmbeds().isEmpty()) { + return message.getContentRaw(); + } + + return message.getEmbeds() + .stream() + .map(MessageEmbed::getDescription) + .collect(Collectors.joining("\n")); + } + @Override public String getName() { return "chatpgt-answer";