Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -92,7 +94,7 @@ private RestAction<Message> createAIResponse(ThreadChannel threadChannel) {
RestAction<Message> originalQuestion =
threadChannel.retrieveMessageById(threadChannel.getIdLong());
return originalQuestion.flatMap(message -> helper.constructChatGptAttempt(threadChannel,
message.getContentRaw(), componentIdInteractor));
getMessageContent(message), componentIdInteractor));
}

private RestAction<Void> pinOriginalQuestion(ThreadChannel threadChannel) {
Expand Down Expand Up @@ -126,6 +128,17 @@ private RestAction<Message> 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";
Expand Down