Add a flag whether messages will save their JSON as a String #1006
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.
The intention of this PR is to be able to access the JSON of a message because there are situations where you may want to save the whole message in a database or in general just processing it.
An example use-case would be to parse the message if you have a dashboard without SSR an no access to Javacords environment.
Since this will also consume more memory and depending on the bots size this is an opt-in feature which you have to set first by setting
DiscordApi#setSaveMessageJsonAsString
to true.If this gets accepted it would also be possible to do a follow-up PR where we can overload methods like
getMessagesAsStream
with a boolean parameter to only save the JSON for specific method calls in addition to having it as a global stateMemory comparison:
Without saving the string: 151.22 Mbyte
With saving the string: 354.13 Mbyte
So when saving the string, it uses ~ 2,3 more memory. This is the result of about 109'000 messages