diff --git a/src/main/java/cc/fascinated/bat/event/EventListener.java b/src/main/java/cc/fascinated/bat/event/EventListener.java index 43c68d5..ef1adbf 100644 --- a/src/main/java/cc/fascinated/bat/event/EventListener.java +++ b/src/main/java/cc/fascinated/bat/event/EventListener.java @@ -10,6 +10,7 @@ import lombok.NonNull; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Invite; import net.dv8tion.jda.api.entities.Role; +import net.dv8tion.jda.api.entities.channel.Channel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; import net.dv8tion.jda.api.entities.emoji.Emoji; @@ -264,6 +265,9 @@ public interface EventListener { default void onGuildUpdateSplash(@NonNull BatGuild guild, String oldSplashUrl, String newSplashUrl, @NonNull GuildUpdateSplashEvent event) { } + default void onChannelUpdateArchived(@NonNull BatGuild guild, @NonNull Channel channel, boolean isArchived, @NonNull ChannelUpdateArchivedEvent event) { + } + default void onShutdown() { } } diff --git a/src/main/java/cc/fascinated/bat/features/logging/LogType.java b/src/main/java/cc/fascinated/bat/features/logging/LogType.java index f6fdab4..bdca383 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/LogType.java +++ b/src/main/java/cc/fascinated/bat/features/logging/LogType.java @@ -43,6 +43,7 @@ public enum LogType { VOICE_CHANNEL_JOIN(LogCategory.CHANNEL), VOICE_CHANNEL_LEAVE(LogCategory.CHANNEL), CHANNEL_CONFIGURATION(LogCategory.CHANNEL), + THREAD_ARCHIVE(LogCategory.CHANNEL), /** * Guild Events 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 0a8811d..dc03a80 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 @@ -14,6 +14,7 @@ import lombok.extern.log4j.Log4j2; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Region; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.Channel; import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; @@ -289,4 +290,14 @@ public class ChannelListener implements EventListener { .build()) .build()); } + + @Override + public void onChannelUpdateArchived(@NonNull BatGuild guild, @NonNull Channel channel, boolean isArchived, @NonNull ChannelUpdateArchivedEvent event) { + log.info("Thread \"{}\" was {} in guild \"{}\"", channel.getName(), isArchived ? "archived" : "unarchived", guild.getName()); + logFeature.sendLog(guild, LogType.THREAD_ARCHIVE, EmbedUtils.successEmbed() + .setDescription(new EmbedDescriptionBuilder("Thread %s".formatted(isArchived ? "Archived" : "Unarchived")) + .appendLine("Channel: %s".formatted(channel.getAsMention()), 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 9514aaf..b2d92e2 100644 --- a/src/main/java/cc/fascinated/bat/service/EventService.java +++ b/src/main/java/cc/fascinated/bat/service/EventService.java @@ -732,4 +732,13 @@ public class EventService extends ListenerAdapter { listener.onGuildUpdateSplash(guild, event.getOldSplashUrl(), event.getNewSplashUrl(), event); } } + + @Override + public void onChannelUpdateArchived(@NotNull ChannelUpdateArchivedEvent event) { + BatGuild guild = guildService.getGuild(event.getGuild().getId()); + + for (EventListener listener : LISTENERS) { + listener.onChannelUpdateArchived(guild, event.getEntity(), event.getNewValue(), event); + } + } }