add role update position log

This commit is contained in:
Lee 2024-07-04 17:54:06 +01:00
parent 3995bf9992
commit 96c4e03e81
3 changed files with 27 additions and 13 deletions

@ -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.message.MessageUpdateEvent;
import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent;
import net.dv8tion.jda.api.events.role.RoleDeleteEvent; 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.*;
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.sticker.GuildStickerAddedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent;
import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent;
import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent; 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 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() { default void onShutdown() {
} }
} }

@ -14,10 +14,7 @@ import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.RoleIcon; import net.dv8tion.jda.api.entities.RoleIcon;
import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent;
import net.dv8tion.jda.api.events.role.RoleDeleteEvent; 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.*;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -142,4 +139,15 @@ public class RoleListener implements EventListener {
.build()) .build())
.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());
}
} }

@ -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.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent;
import net.dv8tion.jda.api.events.role.RoleDeleteEvent; 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.*;
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.sticker.GuildStickerAddedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent;
import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent;
import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent; 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()); BatGuild guild = guildService.getGuild(event.getGuild().getId());
for (EventListener listener : LISTENERS) { 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);
} }
} }
} }