`top_role` color is black when top role has no color.
SwanX1 opened this issue ยท 4 comments
Describe the bug
On Discord the color of the member is the top role with a color. Mc2Discord uses the top role regardless of whether it has a color, and when it doesn't, it defaults to #000000
Your config file
http://m2d.denisd3d.ml/uploads/view?key=5ddc14e0-dd0c-4dc0-ab39-1c27d2e3cd68
Indeed this is an issue. Mc2Discord is using the discord library getHighestRole fonction so I may need to reimplement it to fix this.
I will try too fix this
Thanks for reporting
Possible solution in code
PartialMember.java Line 140
- messageCreateEvent.getMember().get().getHighestRole()
+ MathFlux.max(messageCreateEvent.getMember().get().getRoles().filter(role -> role.getColor() != 0), OrderUtil.ROLE_ORDER)
.map(Role::getColor).map(Color::getRGB).defaultIfEmpty(16777215).subscribe(integer -> {
No idea if this works, I wrote it looking at Discord4J's code and writing this straight in here.
Yes was on that too :)
If you want to make a PR there is an Github Action to compile the mod without installing any dev tools.
I may not be able to do the edit myself for the next week or so
Edit: line that need to be updated are :
- https://github.com/DenisD3D/Mc2Discord/blob/main/mc2discord-core/src/main/java/ml/denisd3d/mc2discord/core/events/DiscordEvents.java#L140
- https://github.com/DenisD3D/Mc2Discord/blob/main/mc2discord-core/src/main/java/ml/denisd3d/mc2discord/core/events/DiscordEvents.java#L156
- https://github.com/DenisD3D/Mc2Discord/blob/main/mc2discord-core/src/main/java/ml/denisd3d/mc2discord/core/account/M2DAccount.java#L150
I've opened PR #68 that fixes this issue