fix: Implementation for Equals & Hashcode in Builder#968
fix: Implementation for Equals & Hashcode in Builder#968Distractic wants to merge 4 commits intokordlib:mainfrom
Conversation
|
As already discussed on Discord I don't really feel like this is the right solution. Kord's builder classes are intended to be short-lived, mutable (!) objects that help to create immutable requests and closely model fields of the Discord API (e.g. optional vs. nullable). Having a data model specific to your domain logic seems to be a way more robust solution to your usecase. I'm also not aware that implementing |
|
Understood. I thought that could be useful for several projects (like Kordex, I think they keep the builders to compare in a next time) but for my need, I can create my own builders, that allows me to have more flexibility than using Kord builder |
|
Nevertheless, thank you for your work :) |
Context
When we compare the builder, like
EmbedBuilder, the comparison between two instances will always return false no matter the field set. For example:This behavior seems to be a bug and needs to be fixed because according to the result, equals & hashcode methods don't work.
Usage
In my bot, when I render my components, I would like to compare the last
InteractionResponseModifyBuilderand the new from the rendering to send only the changed components (embed / actionRow / text) to the discord API and consequently reduce the network load of the botAfter change
If we try the previous code in this PR, this is the result:
The result makes more sense