From 6efb042f14abecf9c9e03745394b448e0ed2f803 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 4 Jul 2024 18:00:16 +0100 Subject: [PATCH] fix role log color --- .../fascinated/bat/event/EventListener.java | 3 +++ .../logging/listeners/RoleListener.java | 24 ++++++++++++++++--- .../fascinated/bat/service/EventService.java | 9 +++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/event/EventListener.java b/src/main/java/cc/fascinated/bat/event/EventListener.java index 73c755b..d266b04 100644 --- a/src/main/java/cc/fascinated/bat/event/EventListener.java +++ b/src/main/java/cc/fascinated/bat/event/EventListener.java @@ -272,6 +272,9 @@ public interface EventListener { @NonNull ChannelUpdatePositionEvent event) { } + default void onRoleUpdateHoisted(@NonNull BatGuild guild, @NonNull Role role, boolean wasHoisted, boolean isHoisted, @NonNull RoleUpdateHoistedEvent event) { + } + default void onShutdown() { } } diff --git a/src/main/java/cc/fascinated/bat/features/logging/listeners/RoleListener.java b/src/main/java/cc/fascinated/bat/features/logging/listeners/RoleListener.java index 615f088..4fa6cc7 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/listeners/RoleListener.java +++ b/src/main/java/cc/fascinated/bat/features/logging/listeners/RoleListener.java @@ -75,7 +75,9 @@ public class RoleListener implements EventListener { logFeature.sendLog(guild, LogType.ROLE_CREATE, EmbedUtils.successEmbed() .setDescription(new EmbedDescriptionBuilder("Role Created") .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) .build()) .build()); @@ -86,8 +88,10 @@ public class RoleListener implements EventListener { log.info("Role \"{}\" was deleted in guild \"{}\"", event.getRole().getName(), guild.getName()); logFeature.sendLog(guild, LogType.ROLE_DELETE, EmbedUtils.successEmbed() .setDescription(new EmbedDescriptionBuilder("Role Deleted") - .appendLine("Role: %s".formatted(event.getRole().getAsMention()), true) - .appendLine("Color: %s".formatted(event.getRole().getColor() == null ? "Default" : event.getRole().getColor()), true) + .appendLine("Role: `%s`".formatted(event.getRole().getName()), true) + .appendLine("Color: `%s`".formatted( + event.getRole().getColor() == null ? "Default" : HexColorUtils.colorToHex(event.getRole().getColor()) + ), true) .appendLine("Position: `%s`".formatted(event.getRole().getPosition()), true) .build()) .build()); @@ -139,4 +143,18 @@ public class RoleListener implements EventListener { .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()); + } } diff --git a/src/main/java/cc/fascinated/bat/service/EventService.java b/src/main/java/cc/fascinated/bat/service/EventService.java index 8d1552f..fa7d7b0 100644 --- a/src/main/java/cc/fascinated/bat/service/EventService.java +++ b/src/main/java/cc/fascinated/bat/service/EventService.java @@ -756,4 +756,13 @@ public class EventService extends ListenerAdapter { 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); + } + } }