Fix dead links in ChatGPT responses (#1276)#1471
Open
VlaM5 wants to merge 1 commit intoTogether-Java:developfrom
Open
Fix dead links in ChatGPT responses (#1276)#1471VlaM5 wants to merge 1 commit intoTogether-Java:developfrom
VlaM5 wants to merge 1 commit intoTogether-Java:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1276
What was done
Approach
The issue proposes two options: ideally sending the response immediately and then editing it after async link checking, or as a fallback - replacing links before sending.
Current (fallback) flow:
post created → ChatGPT generates answer → dead links replaced → embed built → embed sent to Discord
Ideal flow (not implemented):
post created → ChatGPT generates answer → embed sent immediately → links checked in the background → already-sent message edited with clean links
The fallback was chosen because it keeps the change in one place (HelpSystemHelper) and is easy to test. The ideal flow would require mixing two different async mechanisms: checking links uses Java's CompletableFuture (because it makes plain HTTP requests to external sites — JDA is not involved here at all), while sending and editing Discord messages uses JDA's RestAction. These two do not compose directly, so some extra glue code is needed to chain them together correctly.