From 0ba532a9b57decf10becb5faf34857232aa75a6e Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 4 Jul 2024 17:55:10 +0100 Subject: [PATCH] add channel position update log --- .../java/cc/fascinated/bat/event/EventListener.java | 4 ++++ .../features/logging/listeners/ChannelListener.java | 12 ++++++++++++ .../java/cc/fascinated/bat/service/EventService.java | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/src/main/java/cc/fascinated/bat/event/EventListener.java b/src/main/java/cc/fascinated/bat/event/EventListener.java index 005331b..73c755b 100644 --- a/src/main/java/cc/fascinated/bat/event/EventListener.java +++ b/src/main/java/cc/fascinated/bat/event/EventListener.java @@ -268,6 +268,10 @@ public interface EventListener { default void onRoleUpdatePosition(@NonNull BatGuild guild, @NonNull Role role, int oldPosition, int newPosition, @NonNull RoleUpdatePositionEvent event) { } + default void onChannelUpdatePosition(@NonNull BatGuild guild, @NonNull Channel channel, int oldPosition, int newPosition, + @NonNull ChannelUpdatePositionEvent event) { + } + default void onShutdown() { } } diff --git a/src/main/java/cc/fascinated/bat/features/logging/listeners/ChannelListener.java b/src/main/java/cc/fascinated/bat/features/logging/listeners/ChannelListener.java index dc03a80..411e00a 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/listeners/ChannelListener.java +++ b/src/main/java/cc/fascinated/bat/features/logging/listeners/ChannelListener.java @@ -300,4 +300,16 @@ public class ChannelListener implements EventListener { .build()) .build()); } + + @Override + public void onChannelUpdatePosition(@NonNull BatGuild guild, @NonNull Channel channel, int oldPosition, int newPosition, + @NonNull ChannelUpdatePositionEvent event) { + log.info("Channel \"{}\" position was updated from {} to {} in guild \"{}\"", channel.getName(), oldPosition, newPosition, guild.getName()); + logFeature.sendLog(guild, LogType.CHANNEL_CONFIGURATION, EmbedUtils.successEmbed() + .setDescription(new EmbedDescriptionBuilder("Channel Position Updated") + .appendLine("Channel: %s".formatted(channel.getAsMention()), true) + .appendLine("Position: `%s` -> `%s`".formatted(oldPosition, newPosition), 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 59f7fb9..8d1552f 100644 --- a/src/main/java/cc/fascinated/bat/service/EventService.java +++ b/src/main/java/cc/fascinated/bat/service/EventService.java @@ -747,4 +747,13 @@ public class EventService extends ListenerAdapter { listener.onRoleUpdatePosition(guild, event.getRole(), event.getOldPosition(), event.getNewPosition(), event); } } + + @Override + public void onChannelUpdatePosition(@NotNull ChannelUpdatePositionEvent event) { + BatGuild guild = guildService.getGuild(event.getGuild().getId()); + + for (EventListener listener : LISTENERS) { + listener.onChannelUpdatePosition(guild, event.getEntity(), event.getOldValue(), event.getOldValue(), event); + } + } }