diff --git a/src/main/java/cc/fascinated/bat/event/EventListener.java b/src/main/java/cc/fascinated/bat/event/EventListener.java index ef1adbf..005331b 100644 --- a/src/main/java/cc/fascinated/bat/event/EventListener.java +++ b/src/main/java/cc/fascinated/bat/event/EventListener.java @@ -42,10 +42,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageUpdateEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleDeleteEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateColorEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateIconEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateNameEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdatePermissionsEvent; +import net.dv8tion.jda.api.events.role.update.*; import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent; import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent; @@ -268,6 +265,9 @@ public interface EventListener { default void onChannelUpdateArchived(@NonNull BatGuild guild, @NonNull Channel channel, boolean isArchived, @NonNull ChannelUpdateArchivedEvent event) { } + default void onRoleUpdatePosition(@NonNull BatGuild guild, @NonNull Role role, int oldPosition, int newPosition, @NonNull RoleUpdatePositionEvent 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 fe4e79a..b80b903 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 @@ -14,10 +14,7 @@ import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.RoleIcon; import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleDeleteEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateColorEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateIconEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateNameEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdatePermissionsEvent; +import net.dv8tion.jda.api.events.role.update.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -142,4 +139,15 @@ public class RoleListener implements EventListener { .build()) .build()); } + + @Override + public void onRoleUpdatePosition(@NonNull BatGuild guild, @NonNull Role role, int oldPosition, int newPosition, @NonNull RoleUpdatePositionEvent event) { + log.info("Role \"{}\" position was updated in guild \"{}\" from \"{}\" to \"{}\"", role.getName(), guild.getName(), oldPosition, newPosition); + logFeature.sendLog(guild, LogType.ROLE_CONFIGURATION, EmbedUtils.successEmbed() + .setDescription(new EmbedDescriptionBuilder("Role Position Updated") + .appendLine("Role: %s".formatted(role.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 b2d92e2..59f7fb9 100644 --- a/src/main/java/cc/fascinated/bat/service/EventService.java +++ b/src/main/java/cc/fascinated/bat/service/EventService.java @@ -34,10 +34,7 @@ import net.dv8tion.jda.api.events.message.MessageDeleteEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleDeleteEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateColorEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateIconEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdateNameEvent; -import net.dv8tion.jda.api.events.role.update.RoleUpdatePermissionsEvent; +import net.dv8tion.jda.api.events.role.update.*; import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent; import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent; @@ -738,7 +735,16 @@ public class EventService extends ListenerAdapter { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { - listener.onChannelUpdateArchived(guild, event.getEntity(), event.getNewValue(), event); + listener.onChannelUpdateArchived(guild, event.getEntity(), Boolean.TRUE.equals(event.getNewValue()), event); + } + } + + @Override + public void onRoleUpdatePosition(@NotNull RoleUpdatePositionEvent event) { + BatGuild guild = guildService.getGuild(event.getGuild().getId()); + + for (EventListener listener : LISTENERS) { + listener.onRoleUpdatePosition(guild, event.getRole(), event.getOldPosition(), event.getNewPosition(), event); } } }