fix role log color
Some checks failed
Deploy to Dokku / docker (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
Lee 2024-07-04 18:00:16 +01:00
parent 9be80a0f7e
commit 6efb042f14
3 changed files with 33 additions and 3 deletions

@ -272,6 +272,9 @@ public interface EventListener {
@NonNull ChannelUpdatePositionEvent event) { @NonNull ChannelUpdatePositionEvent event) {
} }
default void onRoleUpdateHoisted(@NonNull BatGuild guild, @NonNull Role role, boolean wasHoisted, boolean isHoisted, @NonNull RoleUpdateHoistedEvent event) {
}
default void onShutdown() { default void onShutdown() {
} }
} }

@ -75,7 +75,9 @@ public class RoleListener implements EventListener {
logFeature.sendLog(guild, LogType.ROLE_CREATE, EmbedUtils.successEmbed() logFeature.sendLog(guild, LogType.ROLE_CREATE, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Role Created") .setDescription(new EmbedDescriptionBuilder("Role Created")
.appendLine("Role: %s".formatted(role.getAsMention()), true) .appendLine("Role: %s".formatted(role.getAsMention()), true)
.appendLine("Color: %s".formatted(role.getColor() == null ? "Default" : role.getColor()), true) .appendLine("Color: `%s`".formatted(
role.getColor() == null ? "Default" : HexColorUtils.colorToHex(role.getColor())
), true)
.appendLine("Position: `%s`".formatted(role.getPosition()), true) .appendLine("Position: `%s`".formatted(role.getPosition()), true)
.build()) .build())
.build()); .build());
@ -86,8 +88,10 @@ public class RoleListener implements EventListener {
log.info("Role \"{}\" was deleted in guild \"{}\"", event.getRole().getName(), guild.getName()); log.info("Role \"{}\" was deleted in guild \"{}\"", event.getRole().getName(), guild.getName());
logFeature.sendLog(guild, LogType.ROLE_DELETE, EmbedUtils.successEmbed() logFeature.sendLog(guild, LogType.ROLE_DELETE, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Role Deleted") .setDescription(new EmbedDescriptionBuilder("Role Deleted")
.appendLine("Role: %s".formatted(event.getRole().getAsMention()), true) .appendLine("Role: `%s`".formatted(event.getRole().getName()), true)
.appendLine("Color: %s".formatted(event.getRole().getColor() == null ? "Default" : event.getRole().getColor()), true) .appendLine("Color: `%s`".formatted(
event.getRole().getColor() == null ? "Default" : HexColorUtils.colorToHex(event.getRole().getColor())
), true)
.appendLine("Position: `%s`".formatted(event.getRole().getPosition()), true) .appendLine("Position: `%s`".formatted(event.getRole().getPosition()), true)
.build()) .build())
.build()); .build());
@ -139,4 +143,18 @@ public class RoleListener implements EventListener {
.build()) .build())
.build()); .build());
} }
@Override
public void onRoleUpdateHoisted(@NonNull BatGuild guild, @NonNull Role role, boolean wasHoisted, boolean isHoisted, @NonNull RoleUpdateHoistedEvent event) {
log.info("Role \"{}\" hoisted status was updated in guild \"{}\"", role.getName(), guild.getName());
logFeature.sendLog(guild, LogType.ROLE_CONFIGURATION, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Role Hoisted Status Updated")
.appendLine("Role: %s".formatted(role.getAsMention()), true)
.appendLine("Hoisted: `%s` -> `%s`".formatted(
wasHoisted ? "Yes" : "No",
isHoisted ? "Yes" : "No"
), true)
.build())
.build());
}
} }

@ -756,4 +756,13 @@ public class EventService extends ListenerAdapter {
listener.onChannelUpdatePosition(guild, event.getEntity(), event.getOldValue(), event.getOldValue(), event); listener.onChannelUpdatePosition(guild, event.getEntity(), event.getOldValue(), event.getOldValue(), event);
} }
} }
@Override
public void onRoleUpdateHoisted(@NotNull RoleUpdateHoistedEvent event) {
BatGuild guild = guildService.getGuild(event.getGuild().getId());
for (EventListener listener : LISTENERS) {
listener.onRoleUpdateHoisted(guild, event.getRole(), event.getOldValue(), event.getNewValue(), event);
}
}
} }