From 1d72de7ac2a3173cc4983bcd0943167d2a894873 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Fri, 2 Oct 2026 20:13:23 +0530 Subject: [PATCH 01/17] refactor: remove custom shard manager configuration - this disables the bot's ability to scale horizontally Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .env.example | 5 +---- .../papertrail/bot/BootstrapService.java | 19 ++----------------- .../bot/configuration/PaperTrailConfig.java | 18 ------------------ src/main/resources/application.properties | 9 --------- 4 files changed, 3 insertions(+), 48 deletions(-) diff --git a/.env.example b/.env.example index b314844..ba89461 100644 --- a/.env.example +++ b/.env.example @@ -1,11 +1,8 @@ #Mandatory TOKEN= API_URL= + #Optional -TOTAL_SHARDS= -MIN_SHARD_ID= -MAX_SHARD_ID= -TWILIGHT_HTTP_PROXY_URL= PORT= MANAGEMENT_PORT= GLOBAL_LOG_LEVEL= diff --git a/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java b/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java index ddbca49..5bd5155 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java @@ -12,7 +12,6 @@ import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.requests.GatewayIntent; -import net.dv8tion.jda.api.requests.RestConfig; import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.api.sharding.ShardManager; import net.dv8tion.jda.api.utils.ChunkingFilter; @@ -74,18 +73,6 @@ ShardManager constructShardManager() { builder.addEventListeners(listener); }); - // add shards - builder.setShardsTotal(paperTrailConfig.discord().shard().total()); - builder.setShards(paperTrailConfig.discord().shard().min(), paperTrailConfig.discord().shard().max()); - - // add custom twilight http proxy url if present - // note the current implementation only changes the proxy - // JDA's internal rate limit logic still applies on top of the proxy - // you need to provide a custom RestRateLimiter config - if (!paperTrailConfig.discord().twilightProxyUrl().isBlank()) { // don't use isEmpty cause default value is a whitespace - builder.setRestConfig(new RestConfig().setBaseUrl(paperTrailConfig.discord().twilightProxyUrl())); - } - // build shard manager and login return builder.build(); } @@ -99,9 +86,7 @@ ShardManager getShardManager() { @PreDestroy void shutdown() { - for (int i = paperTrailConfig.discord().shard().min(); i <= paperTrailConfig.discord().shard().max(); i++) { - log.info("Shutting Down Shard: {}", i); - shardManager.shutdown(i); - } + log.info("Shutting down all shards..."); + shardManager.shutdown(); } } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java b/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java index b6c1aa3..91aad7f 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java @@ -34,24 +34,6 @@ interface Discord { @WithName("token") @NonNull String token(); - - @WithName("twilight.http.proxy.url") - @NonNull - String twilightProxyUrl(); - - Shard shard(); - - interface Shard { - - @WithName("min") - int min(); - - @WithName("max") - int max(); - - @WithName("total") - int total(); - } } interface API { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 050f7b6..cd47bd8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,15 +9,6 @@ papertrail.discord.token=${TOKEN} # PaperTrail API URL papertrail.api.url=${API_URL} -# Shard Config -papertrail.discord.shard.min=${MIN_SHARD_ID:0} -papertrail.discord.shard.max=${MAX_SHARD_ID:0} -papertrail.discord.shard.total=${TOTAL_SHARDS:1} - -# Twilight HTTP Proxy URL -# default value is a whitespace -papertrail.discord.twilight.http.proxy.url=${TWILIGHT_HTTP_PROXY_URL: } - #Port quarkus.http.port=${PORT:8080} quarkus.management.enabled=true From 03c4f8bc6c385b2945eeba1b7a763e3b41044886 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Fri, 2 Oct 2026 23:33:57 +0530 Subject: [PATCH 02/17] refactor: update for new schema - brand-new command system - ive been working tirelessly for 10hours..i cant do it anymore Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- pom.xml | 6 +- .../PaperTrailClientBeanProducer.java | 35 ++++ .../configuration/PaperTrailSdkProducer.java | 45 ----- .../configuration/RetrofitBeanProducer.java | 37 ++++ ...stener.java => ConfigCommandListener.java} | 21 ++- .../command/DebugCommandListener.java | 3 +- ...Listener.java => HelpCommandListener.java} | 11 +- .../MessageLogSetupCommandListener.java | 46 ----- .../command/ServerStatCommandListener.java | 3 +- .../guild/GuildBoostEventListener.java | 3 +- .../guild/GuildMemberEventListener.java | 3 +- .../guild/GuildPollEventListener.java | 3 +- .../GuildSecurityIncidentEventListener.java | 3 +- .../guild/GuildVoiceEventListener.java | 3 +- .../GuildAuditLogEntryEventListener.java | 3 +- .../message/GuildMessageEventListener.java | 3 +- .../bot/listeners/misc/SelfKickListener.java | 19 +- .../SlashCommandRegistrationListener.java | 35 ++-- .../command/AuditLogSetupCommandHandler.java | 119 ------------- .../BotSetupInstructionCommandHandler.java | 78 -------- .../command/ConfigCommandHandler.java | 168 ++++++++++++++++++ .../handlers/command/DebugCommandHandler.java | 34 +--- .../handlers/command/HelpCommandHandler.java | 96 ++++++++++ .../MessageLogSetupCommandHandler.java | 119 ------------- .../guild/GuildBoostEventHandler.java | 23 +-- .../guild/GuildMemberEventHandler.java | 21 +-- .../handlers/guild/GuildPollEventHandler.java | 19 +- .../GuildSecurityIncidentEventHandler.java | 21 +-- .../guild/GuildVoiceEventHandler.java | 22 +-- .../auditlog/AutoModActionTypeHandler.java | 33 ++-- .../auditlog/ChannelActionTypeHandler.java | 23 +-- .../ChannelOverrideActionTypeHandler.java | 23 +-- .../auditlog/EmojiActionTypeHandler.java | 23 +-- .../GuildUpdateActionTypeHandler.java | 21 +-- .../HomeSettingsActionTypeHandler.java | 21 +-- .../IntegrationActionTypeHandler.java | 25 +-- .../auditlog/InviteActionTypeHandler.java | 23 +-- .../MemberUpdateActionTypeHandler.java | 25 +-- .../auditlog/MessageActionTypeHandler.java | 21 +-- .../auditlog/MessagePinActionTypeHandler.java | 21 +-- .../auditlog/ModActionActionTypeHandler.java | 27 +-- .../auditlog/OnboardingActionTypeHandler.java | 21 +-- .../OnboardingPromptActionTypeHandler.java | 23 +-- .../guild/auditlog/RoleActionTypeHandler.java | 23 +-- .../ScheduledEventActionTypeHandler.java | 23 +-- .../auditlog/SoundboardActionTypeHandler.java | 23 +-- .../StageInstanceActionTypeHandler.java | 23 +-- .../auditlog/StickerActionTypeHandler.java | 23 +-- .../auditlog/ThreadActionTypeHandler.java | 23 +-- .../auditlog/UnknownActionTypeHandler.java | 19 +- .../VoiceChannelStatusActionTypeHandler.java | 21 +-- .../auditlog/WebhookActionTypeHandler.java | 23 +-- .../message/GuildMessageEventHandler.java | 61 +++---- src/main/resources/application.properties | 1 + 54 files changed, 753 insertions(+), 842 deletions(-) create mode 100644 src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailClientBeanProducer.java delete mode 100644 src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailSdkProducer.java create mode 100644 src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java rename src/main/java/io/github/eggy03/papertrail/bot/listeners/command/{AuditLogSetupCommandListener.java => ConfigCommandListener.java} (55%) rename src/main/java/io/github/eggy03/papertrail/bot/listeners/command/{BotSetupInstructionCommandListener.java => HelpCommandListener.java} (66%) delete mode 100644 src/main/java/io/github/eggy03/papertrail/bot/listeners/command/MessageLogSetupCommandListener.java delete mode 100644 src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/AuditLogSetupCommandHandler.java delete mode 100644 src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/BotSetupInstructionCommandHandler.java create mode 100644 src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java create mode 100644 src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java delete mode 100644 src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/MessageLogSetupCommandHandler.java diff --git a/pom.xml b/pom.xml index e9cc8bf..9d419f2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 6.6.0 - 3.0.3 + 1.0.0 3.20.0 33.7.1-jre 26.1.0 @@ -108,8 +108,8 @@ io.github.eggy03 - papertrail-sdk - ${papertrail.sdk.version} + papertrail-http-client + ${papertrail.http.client.version} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailClientBeanProducer.java b/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailClientBeanProducer.java new file mode 100644 index 0000000..8f7fdfe --- /dev/null +++ b/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailClientBeanProducer.java @@ -0,0 +1,35 @@ +package io.github.eggy03.papertrail.bot.configuration; + +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.client.PaperTrailMessageClient; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Inject; +import lombok.NonNull; +import org.jetbrains.annotations.Contract; +import retrofit2.Retrofit; + +@ApplicationScoped +public final class PaperTrailClientBeanProducer { + + private final @NonNull Retrofit retrofit; + + @Inject + public PaperTrailClientBeanProducer(@NonNull Retrofit retrofit) { + this.retrofit = retrofit; + } + + @Contract(" -> new") + @Produces + @ApplicationScoped + public @NonNull PaperTrailGuildClient paperTrailGuildClient() { + return new PaperTrailGuildClient(retrofit); + } + + @Contract(" -> new") + @Produces + @ApplicationScoped + public @NonNull PaperTrailMessageClient paperTrailMessageClient() { + return new PaperTrailMessageClient(retrofit); + } +} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailSdkProducer.java b/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailSdkProducer.java deleted file mode 100644 index 9a2e29c..0000000 --- a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailSdkProducer.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.github.eggy03.papertrail.bot.configuration; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.client.MessageLogContentClient; -import io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.inject.Produces; -import jakarta.inject.Inject; -import lombok.NonNull; -import org.jetbrains.annotations.Contract; - -@ApplicationScoped -public final class PaperTrailSdkProducer { - - private final @NonNull String apiUrl; - private final @NonNull ObjectMapper objectMapper; - - @Inject - public PaperTrailSdkProducer(@NonNull PaperTrailConfig paperTrailConfig, @NonNull ObjectMapper objectMapper) { - this.apiUrl = paperTrailConfig.api().url(); - this.objectMapper = objectMapper; - } - - @Contract(" -> new") - @Produces - @ApplicationScoped - public @NonNull AuditLogRegistrationClient auditLogRegistrationClient() { - return new AuditLogRegistrationClient(apiUrl, objectMapper); - } - - @Contract(" -> new") - @Produces - @ApplicationScoped - public @NonNull MessageLogRegistrationClient messageLogRegistrationClient() { - return new MessageLogRegistrationClient(apiUrl, objectMapper); - } - - @Contract(" -> new") - @Produces - @ApplicationScoped - public @NonNull MessageLogContentClient messageLogContentClient() { - return new MessageLogContentClient(apiUrl, objectMapper); - } -} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java b/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java new file mode 100644 index 0000000..ac2f392 --- /dev/null +++ b/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java @@ -0,0 +1,37 @@ +package io.github.eggy03.papertrail.bot.configuration; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Inject; +import lombok.NonNull; +import okhttp3.OkHttpClient; +import org.jetbrains.annotations.Contract; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; + +import java.time.Duration; + +@ApplicationScoped +public final class RetrofitBeanProducer { + + private final @NonNull String apiUrl; + private final @NonNull ObjectMapper objectMapper; + + @Inject + public RetrofitBeanProducer(@NonNull PaperTrailConfig paperTrailConfig, @NonNull ObjectMapper objectMapper) { + this.apiUrl = paperTrailConfig.api().url(); + this.objectMapper = objectMapper; + } + + @Contract(" -> new") + @Produces + @ApplicationScoped + public @NonNull Retrofit retrofit() { + return new Retrofit.Builder() + .baseUrl(apiUrl) + .client(new OkHttpClient.Builder().callTimeout(Duration.ofSeconds(60)).readTimeout(Duration.ofSeconds(30)).writeTimeout(Duration.ofSeconds(30)).build()) + .addConverterFactory(JacksonConverterFactory.create(objectMapper)) + .build(); + } +} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/AuditLogSetupCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java similarity index 55% rename from src/main/java/io/github/eggy03/papertrail/bot/listeners/command/AuditLogSetupCommandListener.java rename to src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java index 27f386b..55c34e5 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/AuditLogSetupCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java @@ -1,7 +1,7 @@ package io.github.eggy03.papertrail.bot.listeners.command; import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; -import io.github.eggy03.papertrail.bot.service.handlers.command.AuditLogSetupCommandHandler; +import io.github.eggy03.papertrail.bot.service.handlers.command.ConfigCommandHandler; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; @@ -11,14 +11,13 @@ import java.util.concurrent.ThreadFactory; @Singleton -public final class AuditLogSetupCommandListener extends ListenerAdapter { +public final class ConfigCommandListener extends ListenerAdapter { - private final @NonNull AuditLogSetupCommandHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ConfigCommandHandler handler; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject - public AuditLogSetupCommandListener(@NonNull AuditLogSetupCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { + public ConfigCommandListener(@NonNull ConfigCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { this.handler = handler; this.virtualThreadFactory = virtualThreadFactory; } @@ -26,16 +25,16 @@ public AuditLogSetupCommandListener(@NonNull AuditLogSetupCommandHandler handler @Override public void onSlashCommandInteraction(@NonNull SlashCommandInteractionEvent event) { - if (!event.getName().equals("auditlog") || event.getSubcommandName() == null) { + if (!event.getName().equals("config")) { return; } virtualThreadFactory.newThread(() -> { switch (event.getSubcommandName()) { - case "set" -> handler.setAuditLogging(event); - case "view" -> handler.viewAuditLoggingChannel(event); - case "remove" -> handler.unsetAuditLogging(event); - default -> { + case "save" -> handler.saveGuild(event); + case "view" -> handler.viewGuild(event); + case "update" -> handler.updateGuild(event); + case null, default -> { // do nothing } } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java index 52df670..db3ab87 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java @@ -18,8 +18,7 @@ public final class DebugCommandListener extends ListenerAdapter { private final @NonNull DebugCommandHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public DebugCommandListener(@NonNull DebugCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/BotSetupInstructionCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java similarity index 66% rename from src/main/java/io/github/eggy03/papertrail/bot/listeners/command/BotSetupInstructionCommandListener.java rename to src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java index 075c3a0..86940c9 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/BotSetupInstructionCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java @@ -1,7 +1,7 @@ package io.github.eggy03.papertrail.bot.listeners.command; import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; -import io.github.eggy03.papertrail.bot.service.handlers.command.BotSetupInstructionCommandHandler; +import io.github.eggy03.papertrail.bot.service.handlers.command.HelpCommandHandler; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; @@ -11,14 +11,13 @@ import java.util.concurrent.ThreadFactory; @Singleton -public final class BotSetupInstructionCommandListener extends ListenerAdapter { +public final class HelpCommandListener extends ListenerAdapter { - private final @NonNull BotSetupInstructionCommandHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull HelpCommandHandler handler; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject - public BotSetupInstructionCommandListener(@NonNull BotSetupInstructionCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { + public HelpCommandListener(@NonNull HelpCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { this.handler = handler; this.virtualThreadFactory = virtualThreadFactory; } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/MessageLogSetupCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/MessageLogSetupCommandListener.java deleted file mode 100644 index 945f443..0000000 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/MessageLogSetupCommandListener.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.github.eggy03.papertrail.bot.listeners.command; - -import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; -import io.github.eggy03.papertrail.bot.service.handlers.command.MessageLogSetupCommandHandler; -import jakarta.inject.Inject; -import jakarta.inject.Singleton; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; - -import java.util.concurrent.ThreadFactory; - -@Slf4j -@Singleton -public final class MessageLogSetupCommandListener extends ListenerAdapter { - - private final @NonNull MessageLogSetupCommandHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; - - @Inject - public MessageLogSetupCommandListener(@NonNull MessageLogSetupCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { - this.handler = handler; - this.virtualThreadFactory = virtualThreadFactory; - } - - @Override - public void onSlashCommandInteraction(@NonNull SlashCommandInteractionEvent event) { - - if (!event.getName().equals("messagelog") || event.getSubcommandName() == null) { - return; - } - - virtualThreadFactory.newThread(() -> { - switch (event.getSubcommandName()) { - case "set" -> handler.setMessageLogging(event); - case "view" -> handler.viewMessageLoggingChannel(event); - case "remove" -> handler.unsetMessageLogging(event); - default -> { - // skip - } - } - }).start(); - } -} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java index bc3cafb..d1b45e7 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java @@ -17,8 +17,7 @@ public final class ServerStatCommandListener extends ListenerAdapter { private final @NonNull ServerStatCommandHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public ServerStatCommandListener(@NonNull ServerStatCommandHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java index 553299f..eb1fa7f 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java @@ -18,8 +18,7 @@ public final class GuildBoostEventListener extends ListenerAdapter { private final @NonNull GuildBoostEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildBoostEventListener(@NonNull GuildBoostEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java index f52ea41..69aeaac 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java @@ -19,8 +19,7 @@ public final class GuildMemberEventListener extends ListenerAdapter { private final @NonNull GuildMemberEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildMemberEventListener(@NonNull GuildMemberEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java index e3154c5..ac67bb9 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java @@ -17,8 +17,7 @@ public final class GuildPollEventListener extends ListenerAdapter { private final @NonNull GuildPollEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildPollEventListener(@NonNull GuildPollEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java index 28a235b..6edd7e4 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java @@ -17,8 +17,7 @@ public final class GuildSecurityIncidentEventListener extends ListenerAdapter { private final @NonNull GuildSecurityIncidentEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildSecurityIncidentEventListener(@NonNull GuildSecurityIncidentEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java index 77a5d65..2a19e55 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java @@ -18,8 +18,7 @@ public final class GuildVoiceEventListener extends ListenerAdapter { private final @NonNull GuildVoiceEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildVoiceEventListener(@NonNull GuildVoiceEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java index 35b0b30..69200cc 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java @@ -34,8 +34,7 @@ public final class GuildAuditLogEntryEventListener extends ListenerAdapter { private final @NonNull Instance handlerInstances; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildAuditLogEntryEventListener(@NonNull Instance handlerInstances, diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java index 5b6069f..8ac055d 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java @@ -16,8 +16,7 @@ public final class GuildMessageEventListener extends ListenerAdapter { private final @NonNull GuildMessageEventHandler handler; - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject public GuildMessageEventListener(@NonNull GuildMessageEventHandler handler, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java index 1d7e827..44786aa 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java @@ -1,8 +1,7 @@ package io.github.eggy03.papertrail.bot.listeners.misc; import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; @@ -19,18 +18,13 @@ public final class SelfKickListener extends ListenerAdapter { @NonNull - private final AuditLogRegistrationClient auditLogRegistrationClient; + private final PaperTrailGuildClient paperTrailGuildClient; - @NonNull - private final MessageLogRegistrationClient messageLogRegistrationClient; - - private final @NonNull - @VirtualThreadFactory ThreadFactory virtualThreadFactory; + private final @NonNull ThreadFactory virtualThreadFactory; @Inject - public SelfKickListener(@NonNull AuditLogRegistrationClient auditLogRegistrationClient, @NonNull MessageLogRegistrationClient messageLogRegistrationClient, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { - this.auditLogRegistrationClient = auditLogRegistrationClient; - this.messageLogRegistrationClient = messageLogRegistrationClient; + public SelfKickListener(@NonNull PaperTrailGuildClient paperTrailGuildClient, @NonNull @VirtualThreadFactory ThreadFactory virtualThreadFactory) { + this.paperTrailGuildClient = paperTrailGuildClient; this.virtualThreadFactory = virtualThreadFactory; } @@ -39,8 +33,7 @@ public void onGuildLeave(@NonNull GuildLeaveEvent event) { Guild leftGuild = event.getGuild(); virtualThreadFactory.newThread(() -> { - auditLogRegistrationClient.deleteRegisteredGuild(leftGuild.getId()); - messageLogRegistrationClient.deleteRegisteredGuild(leftGuild.getId()); + paperTrailGuildClient.deleteGuild(leftGuild.getId()); }).start(); } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java index 938a511..3bdaaca 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java @@ -7,6 +7,7 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.InteractionContextType; import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; +import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.CommandData; import net.dv8tion.jda.api.interactions.commands.build.Commands; import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; @@ -24,29 +25,33 @@ public void onReady(@NonNull ReadyEvent event) { private void setAuditLogCommands(@NonNull JDA jda) { - CommandData auditLog = Commands - .slash("auditlog", "manage audit log options") + // main commands + CommandData config = Commands + .slash("config", "Configures the bot in your guild") .setContexts(InteractionContextType.GUILD) .setDefaultPermissions(DefaultMemberPermissions.DISABLED) - .addSubcommands(new SubcommandData("set", "set audit log channel here")) - .addSubcommands(new SubcommandData("view", "view audit log channel")) - .addSubcommands(new SubcommandData("remove", "unset audit log channel")); + .addSubcommands( + new SubcommandData("save", "Creates a configuration for your guild") + .addOption(OptionType.CHANNEL, "guild_event_channel", "Set channel for guild events", false) + .addOption(OptionType.CHANNEL, "member_event_channel", "Set channel for member events", false) + .addOption(OptionType.CHANNEL, "message_event_channel", "Set channel for message events", false), - CommandData messageLog = Commands - .slash("messagelog", "manage message log options") - .setContexts(InteractionContextType.GUILD) - .setDefaultPermissions(DefaultMemberPermissions.DISABLED) - .addSubcommands(new SubcommandData("set", "set message log channel here")) - .addSubcommands(new SubcommandData("view", "view message log channel")) - .addSubcommands(new SubcommandData("remove", "unset message log channel")); + new SubcommandData("view", "Shows the current configuration for your guild"), + + new SubcommandData("update", "Updates the current configuration") + .addOption(OptionType.CHANNEL, "guild_event_channel", "Set channel for guild events", false) + .addOption(OptionType.CHANNEL, "member_event_channel", "Set channel for member events", false) + .addOption(OptionType.CHANNEL, "message_event_channel", "Set channel for message events", false) + ); + // general commands CommandData serverStats = Commands .slash("stats", "Provides Server Statistics") .setContexts(InteractionContextType.GUILD) .setDefaultPermissions(DefaultMemberPermissions.ENABLED); - CommandData setup = Commands - .slash("setup", "Provides a guide on setting up the bot") + CommandData help = Commands + .slash("help", "Provides a guide on setting up the bot") .setContexts(InteractionContextType.GUILD) .setDefaultPermissions(DefaultMemberPermissions.ENABLED); @@ -56,7 +61,7 @@ private void setAuditLogCommands(@NonNull JDA jda) { .setDefaultPermissions(DefaultMemberPermissions.ENABLED); jda.updateCommands() - .addCommands(auditLog, messageLog, serverStats, setup, debug) + .addCommands(config, serverStats, help, debug) .queue(); } } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/AuditLogSetupCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/AuditLogSetupCommandHandler.java deleted file mode 100644 index f408073..0000000 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/AuditLogSetupCommandHandler.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.github.eggy03.papertrail.bot.service.handlers.command; - -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.utils.MarkdownUtil; - -import java.awt.Color; -import java.util.Optional; - -@ApplicationScoped -@Slf4j -public final class AuditLogSetupCommandHandler { - - private final @NonNull AuditLogRegistrationClient client; - - @Inject - public AuditLogSetupCommandHandler(@NonNull AuditLogRegistrationClient client) { - this.client = client; - } - - public void setAuditLogging(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - GuildChannel callerChannel = event.getChannel().asTextChannel(); - if (callerGuild == null) { - log.warn("An audit log set command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to register the guild and the channel - boolean success = client.registerGuild(callerGuild.getId(), callerChannel.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("Audit Log Registration Process"); - - if (success) { - eb.setColor(Color.GREEN); - eb.addField(MarkdownUtil.underline("Registration Success"), MarkdownUtil.codeblock("All audit log info will be logged here"), false); - } else { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Registration Failure"), MarkdownUtil.codeblock("Channel could not be registered. Check if a channel in this guild is already registered for logging."), false); - } - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } - - public void viewAuditLoggingChannel(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - if (callerGuild == null) { - log.warn("An audit log view command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to retrieve the registered channel - Optional response = client.getRegisteredGuild(callerGuild.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("View Existing Audit Log Configuration"); - - // if there is no channel_id for the given guild_id returned by the API, then inform - // the user of the same, else link the channel that has been registered - response.ifPresentOrElse(success -> { - String registeredChannelId = success.getChannelId(); - GuildChannel registeredChannel = event.getJDA().getGuildChannelById(registeredChannelId); - String registeredChannelName = registeredChannel != null ? registeredChannel.getName() : registeredChannelId; - - eb.setColor(Color.CYAN); - eb.addField(MarkdownUtil.underline("Success"), MarkdownUtil.codeblock(registeredChannelName + " is found to be registered as the audit log channel"), false); - }, () -> { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Warning"), MarkdownUtil.codeblock("No channel has been registered for audit logs"), false); - }); - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } - - public void unsetAuditLogging(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - if (callerGuild == null) { - log.warn("An audit log unset command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to unregister guild - boolean success = client.deleteRegisteredGuild(callerGuild.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("Audit Log Removal Process"); - - if (success) { - eb.setColor(Color.GREEN); - eb.addField(MarkdownUtil.underline("Removal Success"), MarkdownUtil.codeblock("Channel successfully unset"), false); - } else { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Removal Failure"), MarkdownUtil.codeblock("Channel could not be unset. This may be because no channel has been registered in this guild yet."), false); - } - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } -} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/BotSetupInstructionCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/BotSetupInstructionCommandHandler.java deleted file mode 100644 index f690669..0000000 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/BotSetupInstructionCommandHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.github.eggy03.papertrail.bot.service.handlers.command; - -import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import lombok.NonNull; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; - -import java.awt.Color; -import java.time.Instant; - -@ApplicationScoped -public final class BotSetupInstructionCommandHandler { - - private final @NonNull PaperTrailConfig paperTrailConfig; - - @Inject - public BotSetupInstructionCommandHandler(@NonNull PaperTrailConfig paperTrailConfig) { - this.paperTrailConfig = paperTrailConfig; - } - - public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("🛠️ Setup Guide for " + paperTrailConfig.general().appName()); - eb.setDescription("Follow the instructions below to set up the bot in your server."); - eb.setColor(Color.decode("#38e8bc")); - - eb.addField("1️⃣ Set Audit Log Channel", - "Use `/auditlog set` to **register this channel** for receiving audit log events.", - false); - - eb.addField("2️⃣ View Audit Log Channel", - "Use `/auditlog view` to **see which channel** is currently receiving audit logs.", - false); - - eb.addField("3️⃣ Remove Audit Log Channel", - "Use `/auditlog remove` to **stop logging** events and remove the registered channel.", - false); - - eb.addField("🔒 Permissions", - "These three commands require the **Administrator** permission.", - false); - - eb.addBlankField(false); - - eb.addField("4️⃣ Set Message Log Channel", - "Use `/messagelog set` to **register this channel** for receiving message logs.", - false); - - eb.addField("5️⃣ View Message Log Channel", - "Use `/messagelog view` to **see which channel** is currently receiving message logs.", - false); - - eb.addField("6️⃣ Remove Message Log Channel", - "Use `/messagelog remove` to **stop logging** messages and remove the registered channel.", - false); - - eb.addField("🔒 Permissions", - "These three commands require the **Administrator** permission.", - false); - - eb.addBlankField(false); - - eb.addField("7️⃣ View Server Stats", - "Use `/stats` to **view useful server information**, including member count, channel count, and more.", - false); - - eb.addField("📬 Need help?", "Create an issue on [GitHub](" + paperTrailConfig.general().githubIssueLink() + ")", false); - eb.setFooter(paperTrailConfig.general().appName() + " " + paperTrailConfig.general().appVersion()); - eb.setTimestamp(Instant.now()); - - MessageEmbed mb = eb.build(); - event.replyEmbeds(mb).queue(); - } -} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java new file mode 100644 index 0000000..662d7b6 --- /dev/null +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java @@ -0,0 +1,168 @@ +package io.github.eggy03.papertrail.bot.service.handlers.command; + +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; +import net.dv8tion.jda.api.utils.MarkdownUtil; + +import java.awt.Color; +import java.util.Optional; + +@ApplicationScoped +@Slf4j +@SuppressWarnings("java:S1192") +public final class ConfigCommandHandler { + + private final @NonNull PaperTrailGuildClient client; + + @Inject + public ConfigCommandHandler(@NonNull PaperTrailGuildClient client) { + this.client = client; + } + + public void saveGuild(@NonNull SlashCommandInteractionEvent event) { + + Guild callerGuild = event.getGuild(); + if (callerGuild == null) { + log.warn("An audit log set command may have been called outside of a guild. This should not happen."); + return; + } + + // acknowledge this interaction before calling the API + event.deferReply().queue(); + + OptionMapping guildEventChannelOption = event.getOption("guild_event_channel"); + OptionMapping memberEventChannelOption = event.getOption("member_event_channel"); + OptionMapping messageEventChannelOption = event.getOption("message_event_channel"); + + String guildEventChannelId = guildEventChannelOption == null ? null : guildEventChannelOption.getAsChannel().getId(); + String memberEventChannelId = memberEventChannelOption == null ? null : memberEventChannelOption.getAsChannel().getId(); + String messageEventChannelId = messageEventChannelOption == null ? null : messageEventChannelOption.getAsChannel().getId(); + + // Call the API to register the guild and the channel + boolean success = client.saveGuild(callerGuild.getId(), guildEventChannelId, memberEventChannelId, messageEventChannelId); + + EmbedBuilder eb = new EmbedBuilder(); + eb.setTitle("Bot Setup Process"); + + if (success) { + eb.setColor(Color.GREEN); + eb.addField(MarkdownUtil.underline("Setup Success"), MarkdownUtil.codeblock("Events will be logged in your set channels"), false); + } else { + eb.setColor(Color.YELLOW); + eb.addField(MarkdownUtil.underline("Setup Failure"), MarkdownUtil.codeblock("Channels could not be registered. This could be due to an existing configuration. You must also provide at least one channel during setup."), false); + } + + event.getHook().editOriginalEmbeds(eb.build()).queue(); + } + + public void viewGuild(@NonNull SlashCommandInteractionEvent event) { + + Guild callerGuild = event.getGuild(); + if (callerGuild == null) { + log.warn("An audit log view command may have been called outside of a guild. This should not happen."); + return; + } + + // acknowledge this interaction before calling the API + event.deferReply().queue(); + + // Call the API to retrieve the registered channel + Optional response = client.getGuild(callerGuild.getId()); + + EmbedBuilder eb = new EmbedBuilder(); + eb.setTitle("View Existing Configuration"); + + // if no guild object returned by the API, then inform + // the user that no channel has been registered, else resolve the channels + response.ifPresentOrElse(success -> { + + String guildEventChannelId = success.guildEventChannelId(); + String memberEventChannelId = success.memberEventChannelId(); + String messageEventChannelId = success.messageEventChannelId(); + + GuildChannel guildEventChannel = guildEventChannelId == null ? null : event.getJDA().getGuildChannelById(guildEventChannelId); + GuildChannel memberEventChannel = memberEventChannelId == null ? null : event.getJDA().getGuildChannelById(memberEventChannelId); + GuildChannel messageEventChannel = messageEventChannelId == null ? null : event.getJDA().getGuildChannelById(messageEventChannelId); + + String guildEventChannelJumpUrl = guildEventChannel == null ? "Not Available" : guildEventChannel.getJumpUrl(); + String memberEventChannelJumpUrl = memberEventChannel == null ? "Not Available" : memberEventChannel.getJumpUrl(); + String messageEventChannelJumpUrl = messageEventChannel == null ? "Not Available" : messageEventChannel.getJumpUrl(); + + eb.setColor(Color.CYAN); + eb.addField(MarkdownUtil.underline("Guild Event Channel"), guildEventChannelJumpUrl, false); + eb.addField(MarkdownUtil.underline("Member Event Channel"), memberEventChannelJumpUrl, false); + eb.addField(MarkdownUtil.underline("Message Event Channel"), messageEventChannelJumpUrl, false); + }, () -> { + eb.setColor(Color.YELLOW); + eb.addField(MarkdownUtil.underline("Warning"), MarkdownUtil.codeblock("No Configuration Found"), false); + }); + + event.getHook().editOriginalEmbeds(eb.build()).queue(); + } + + public void updateGuild(@NonNull SlashCommandInteractionEvent event) { + + Guild callerGuild = event.getGuild(); + if (callerGuild == null) { + log.warn("An audit log unset command may have been called outside of a guild. This should not happen."); + return; + } + + // acknowledge this interaction before calling the API + event.deferReply().queue(); + + OptionMapping guildEventChannelOption = event.getOption("guild_event_channel"); + OptionMapping memberEventChannelOption = event.getOption("member_event_channel"); + OptionMapping messageEventChannelOption = event.getOption("message_event_channel"); + + // if all the options are null, unregister the guild + if (guildEventChannelOption == null && memberEventChannelOption == null && messageEventChannelOption == null) { + boolean success = client.deleteGuild(callerGuild.getId()); + + EmbedBuilder eb = new EmbedBuilder(); + eb.setTitle("Delete Existing Configuration"); + + if (success) { + eb.setColor(Color.GREEN); + eb.addField(MarkdownUtil.underline("Deletion Success"), MarkdownUtil.codeblock("Configuration Deleted"), false); + } else { + eb.setColor(Color.YELLOW); + eb.addField(MarkdownUtil.underline("Deletion Failure"), MarkdownUtil.codeblock("No Configuration Found."), false); + } + + event.getHook().editOriginalEmbeds(eb.build()).queue(); + return; + } + + // else update guild + String guildEventChannelId = guildEventChannelOption == null ? null : guildEventChannelOption.getAsChannel().getId(); + String memberEventChannelId = memberEventChannelOption == null ? null : memberEventChannelOption.getAsChannel().getId(); + String messageEventChannelId = messageEventChannelOption == null ? null : messageEventChannelOption.getAsChannel().getId(); + + // Call the API to update channel + boolean success = client.updateGuild(callerGuild.getId(), guildEventChannelId, memberEventChannelId, messageEventChannelId); + + EmbedBuilder eb = new EmbedBuilder(); + eb.setTitle("Update Existing Configuration"); + + if (success) { + eb.setColor(Color.GREEN); + eb.addField(MarkdownUtil.underline("Update Success"), MarkdownUtil.codeblock("Configuration Has Been Updated"), false); + } else { + eb.setColor(Color.YELLOW); + eb.addField(MarkdownUtil.underline("Update Failure"), MarkdownUtil.codeblock("No Configuration Found."), false); + } + + event.getHook().editOriginalEmbeds(eb.build()).queue(); + + } +} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java index 6953b01..4176331 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java @@ -3,8 +3,6 @@ import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.PermissionUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -24,14 +22,10 @@ @ApplicationScoped public final class DebugCommandHandler { - private final @NonNull AuditLogRegistrationClient auditLogRegistrationClient; - private final @NonNull MessageLogRegistrationClient messageLogRegistrationClient; private final @NonNull PaperTrailConfig paperTrailConfig; @Inject - public DebugCommandHandler(@NonNull AuditLogRegistrationClient auditLogRegistrationClient, @NonNull MessageLogRegistrationClient messageLogRegistrationClient, @NonNull PaperTrailConfig paperTrailConfig) { - this.auditLogRegistrationClient = auditLogRegistrationClient; - this.messageLogRegistrationClient = messageLogRegistrationClient; + public DebugCommandHandler(@NonNull PaperTrailConfig paperTrailConfig) { this.paperTrailConfig = paperTrailConfig; } @@ -51,8 +45,8 @@ public void sendDebugInfo(@NonNull SlashCommandInteractionEvent event, @NonNull eb.addField(MarkdownUtil.underline("Server Info"), MarkdownUtil.quoteBlock(getServerInfo(guild, channel)), true); eb.addField(MarkdownUtil.underline("User Info"), MarkdownUtil.quoteBlock(getCallerInfo(member)), true); + eb.addBlankField(true); eb.addField(MarkdownUtil.underline("Bot Info"), MarkdownUtil.quoteBlock(getBotInfo(event)), true); - eb.addField(MarkdownUtil.underline("Configuration Info"), MarkdownUtil.quoteBlock(getConfigurationInfo(guild)), true); eb.setFooter(paperTrailConfig.general().appName() + " " + paperTrailConfig.general().appVersion()); eb.setTimestamp(Instant.now()); @@ -124,28 +118,4 @@ private String getBotInfo(@NonNull SlashCommandInteractionEvent event) { return "Current Shard ID: " + shardInfo.getShardId() + "\n" + "Total Shards: " + shardInfo.getShardTotal(); } - - @NonNull - private String getConfigurationInfo(@NonNull Guild guild) { - - StringBuilder sb = new StringBuilder(); - - auditLogRegistrationClient.getRegisteredGuild(guild.getId()).ifPresentOrElse(entity -> { - GuildChannel channel = guild.getGuildChannelById(entity.getChannelId()); - if (channel != null) - sb.append("Registered Audit Log Channel: ").append(MarkdownUtil.underline(channel.getName())).append("\n"); - else - sb.append("Registered Audit Log Channel: ").append(MarkdownUtil.underline("Registered Channel Unresolvable")).append("\n"); - }, () -> sb.append(MarkdownUtil.underline("No Channel Registered For Audit Logging")).append("\n")); - - messageLogRegistrationClient.getRegisteredGuild(guild.getId()).ifPresentOrElse(entity -> { - GuildChannel channel = guild.getGuildChannelById(entity.getChannelId()); - if (channel != null) - sb.append("Registered Message Log Channel: ").append(MarkdownUtil.underline(channel.getName())); - else - sb.append("Registered Message Log Channel: ").append(MarkdownUtil.underline("Registered Channel Unresolvable")); - }, () -> sb.append(MarkdownUtil.underline("No Channel Registered For Message Logging"))); - - return sb.toString(); - } } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java new file mode 100644 index 0000000..fb877cf --- /dev/null +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java @@ -0,0 +1,96 @@ +package io.github.eggy03.papertrail.bot.service.handlers.command; + +import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import lombok.NonNull; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; + +import java.awt.Color; +import java.time.Instant; + +@ApplicationScoped +public final class HelpCommandHandler { + + private final @NonNull PaperTrailConfig paperTrailConfig; + + @Inject + public HelpCommandHandler(@NonNull PaperTrailConfig paperTrailConfig) { + this.paperTrailConfig = paperTrailConfig; + } + + public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { + + EmbedBuilder eb = new EmbedBuilder(); + + eb.setTitle("🛠️ Setup Guide for " + paperTrailConfig.general().appName()); + eb.setDescription("Configure PaperTrailBot to receive different types of server events in separate channels."); + eb.setColor(Color.decode("#38e8bc")); + + eb.addField("Initial Setup", + "Use `/setup save` to save your server configuration. You can provide one or more event channels during setup.", + false + ); + + eb.addField( + "Guild Events", + "The **Guild Event Channel** receives events related to the server itself", + false + ); + + eb.addField( + "Member Events", + "The **Member Event Channel** receives events related to server members", + false + ); + + eb.addField( + "Message Events", + "The **Message Event Channel** receives message-related events and logs.", + false + ); + + eb.addField( + "View Configuration", + "Use `/setup view` to **see the channels currently configured** ", + false + ); + + eb.addField( + "Update Configuration", + "Use `/setup update` to **update your event channel configuration**. " + + "Any channel option that is not provided will be **cleared** and set to no channel.", + false + ); + + eb.addField( + "Remove Configuration", + "Use `/setup update` without providing any event channels to " + + "**remove the existing server configuration**.", + false + ); + + eb.addField( + "🔒 Permissions", + "Setup configuration commands require the **Administrator** permission.", + false + ); + + eb.addBlankField(false); + + eb.addBlankField(false); + + eb.addField("View Server Stats", + "Use `/stats` to **view useful server information**.", + false); + + eb.addField("📬 Need help?", "Create an issue on [GitHub](" + paperTrailConfig.general().githubIssueLink() + ")", false); + eb.setFooter(paperTrailConfig.general().appName() + " " + paperTrailConfig.general().appVersion()); + eb.setTimestamp(Instant.now()); + + MessageEmbed mb = eb.build(); + event.replyEmbeds(mb).queue(); + } +} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/MessageLogSetupCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/MessageLogSetupCommandHandler.java deleted file mode 100644 index 95cb097..0000000 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/MessageLogSetupCommandHandler.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.github.eggy03.papertrail.bot.service.handlers.command; - -import io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.MessageLogRegistrationEntity; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.utils.MarkdownUtil; - -import java.awt.Color; -import java.util.Optional; - -@ApplicationScoped -@Slf4j -public final class MessageLogSetupCommandHandler { - - private final @NonNull MessageLogRegistrationClient client; - - @Inject - public MessageLogSetupCommandHandler(@NonNull MessageLogRegistrationClient client) { - this.client = client; - } - - public void setMessageLogging(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - GuildChannel callerChannel = event.getChannel().asTextChannel(); - if (callerGuild == null) { - log.warn("A message log set command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to register guild for message logging - boolean success = client.registerGuild(callerGuild.getId(), callerChannel.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("Message Log Registration Process"); - - if (success) { - eb.setColor(Color.GREEN); - eb.addField(MarkdownUtil.underline("Registration Success"), MarkdownUtil.codeblock("All edited and deleted messages will be logged here"), false); - } else { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Registration Failure"), MarkdownUtil.codeblock("Channel could not be registered. Check if a channel in this guild is already registered for logging."), false); - - } - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } - - public void viewMessageLoggingChannel(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - if (callerGuild == null) { - log.warn("A message log view command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to check for registered guild - Optional response = client.getRegisteredGuild(callerGuild.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("View Existing Message Log Configuration"); - - response.ifPresentOrElse(success -> { - - String registeredChannelId = success.getChannelId(); - GuildChannel registeredChannel = event.getJDA().getGuildChannelById(registeredChannelId); - String registeredChannelName = registeredChannel != null ? registeredChannel.getName() : registeredChannelId; - - eb.setColor(Color.CYAN); - eb.addField(MarkdownUtil.underline("Success"), MarkdownUtil.codeblock(registeredChannelName + " is found to be registered as the message log channel"), false); - }, () -> { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Warning"), MarkdownUtil.codeblock("No channel has been registered for message logs"), false); - }); - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } - - public void unsetMessageLogging(@NonNull SlashCommandInteractionEvent event) { - - Guild callerGuild = event.getGuild(); - if (callerGuild == null) { - log.warn("A message log unset command may have been called outside of a guild. This should not happen."); - return; - } - - // acknowledge this interaction before calling the API - event.deferReply().queue(); - - // Call the API to unregister guild - boolean success = client.deleteRegisteredGuild(callerGuild.getId()); - - EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("Message Log Removal Process"); - - if (success) { - eb.setColor(Color.GREEN); - eb.addField(MarkdownUtil.underline("Removal Success"), MarkdownUtil.codeblock("Channel successfully unset"), false); - } else { - eb.setColor(Color.YELLOW); - eb.addField(MarkdownUtil.underline("Removal Failure"), MarkdownUtil.codeblock("Channel could not be unset. This may be because no channel has been registered in this guild yet."), false); - } - - event.getHook().editOriginalEmbeds(eb.build()).queue(); - } -} diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java index d0e5c26..dde3e84 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -14,7 +14,7 @@ import net.dv8tion.jda.api.events.guild.update.GuildUpdateBoostCountEvent; import net.dv8tion.jda.api.events.guild.update.GuildUpdateBoostTierEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -24,25 +24,26 @@ @Slf4j public final class GuildBoostEventHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildBoostEventHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildBoostEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } public void handleUpdateBoostTier(@NonNull GuildUpdateBoostTierEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Guild guild = event.getGuild(); @@ -76,7 +77,7 @@ public void handleUpdateBoostTier(@NonNull GuildUpdateBoostTierEvent event) { public void handleUpdateBoostCount(@NonNull GuildUpdateBoostCountEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Guild guild = event.getGuild(); @@ -97,7 +98,7 @@ public void handleUpdateBoostCount(@NonNull GuildUpdateBoostCountEvent event) { public void handleMemberUpdateBoostTime(@NonNull GuildMemberUpdateBoostTimeEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Member member = event.getMember(); Guild guild = event.getGuild(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java index 4b905c9..d1ba932 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -17,7 +17,7 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; import net.dv8tion.jda.api.utils.TimeFormat; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -26,25 +26,26 @@ @Slf4j public final class GuildMemberEventHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildMemberEventHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildMemberEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::memberEventChannelId) + .orElse(null); } public void handleGuildMemberJoin(@NonNull GuildMemberJoinEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Guild guild = event.getGuild(); User user = event.getUser(); @@ -69,7 +70,7 @@ public void handleGuildMemberJoin(@NonNull GuildMemberJoinEvent event) { public void handleGuildMemberRemove(@NonNull GuildMemberRemoveEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Guild guild = event.getGuild(); User user = event.getUser(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java index c09f806..6348e8e 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; import net.dv8tion.jda.api.utils.TimeFormat; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -22,19 +22,20 @@ @Slf4j public final class GuildPollEventHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildPollEventHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildPollEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -45,7 +46,7 @@ public void handlePollCreationEvent(@NonNull MessageReceivedEvent event) { return; String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Poll Creation Event"); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java index b3cb66b..2f008a5 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.DurationUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -14,7 +14,7 @@ import net.dv8tion.jda.api.events.guild.update.GuildUpdateSecurityIncidentActionsEvent; import net.dv8tion.jda.api.events.guild.update.GuildUpdateSecurityIncidentDetectionsEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -24,25 +24,26 @@ @Slf4j public final class GuildSecurityIncidentEventHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildSecurityIncidentEventHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildSecurityIncidentEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecurityIncidentDetectionsEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; SecurityIncidentDetections oldSID = event.getOldSecurityIncidentDetections(); SecurityIncidentDetections newSID = event.getNewSecurityIncidentDetections(); @@ -104,7 +105,7 @@ public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecu public void handleGuildUpdateSecurityIncidentActions(@NonNull GuildUpdateSecurityIncidentActionsEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; SecurityIncidentActions oldSIA = event.getOldSecurityIncidentActions(); SecurityIncidentActions newSIA = event.getNewSecurityIncidentActions(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java index 6c54cd6..cb790b8 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -21,26 +21,26 @@ @Slf4j public final class GuildVoiceEventHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildVoiceEventHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildVoiceEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull - private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + private @Nullable String getRegisteredChannelId(@NonNull String guildId) { + return client.getGuild(guildId) + .map(PaperTrailGuild::memberEventChannelId) + .orElse(null); } - + public void handleVoiceUpdateEvent(@NonNull GuildVoiceUpdateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; Member member = event.getMember(); AudioChannel left = event.getOldValue(); // can be null if user joined for first time diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java index 1532736..7837f6f 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.AutoModUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.automod.AutoModRule; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,27 +24,28 @@ @SuppressWarnings("java:S1192") public final class AutoModActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public AutoModActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public AutoModActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @Override public void onAutoModerationFlagToChannel(@NonNull GuildAuditLogEntryCreateEvent event) { - + String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -74,7 +75,7 @@ public void onAutoModerationFlagToChannel(@NonNull GuildAuditLogEntryCreateEvent public void onAutoModerationMemberTimeout(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -103,7 +104,7 @@ public void onAutoModerationMemberTimeout(@NonNull GuildAuditLogEntryCreateEvent public void onAutoModerationRuleBlockMessage(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -133,7 +134,7 @@ public void onAutoModerationRuleBlockMessage(@NonNull GuildAuditLogEntryCreateEv public void onAutoModerationRuleCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -180,7 +181,7 @@ public void onAutoModerationRuleCreate(@NonNull GuildAuditLogEntryCreateEvent ev public void onAutoModerationRuleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -209,7 +210,7 @@ public void onAutoModerationRuleUpdate(@NonNull GuildAuditLogEntryCreateEvent ev public void onAutoModerationRuleDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -241,7 +242,7 @@ public void onAutoModerationRuleDelete(@NonNull GuildAuditLogEntryCreateEvent ev public void onAutoModerationQuarantineUser(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java index faea722..3358991 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java @@ -4,8 +4,8 @@ import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.ChannelUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -16,7 +16,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -25,19 +25,20 @@ @SuppressWarnings("java:S1192") public final class ChannelActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ChannelActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ChannelActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -45,7 +46,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onChannelCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -109,7 +110,7 @@ public void onChannelCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onChannelUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -222,7 +223,7 @@ public void onChannelUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onChannelDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java index f60f843..b8c7b65 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.ChannelUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -16,7 +16,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -25,19 +25,20 @@ @SuppressWarnings("java:S1192") public final class ChannelOverrideActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ChannelOverrideActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ChannelOverrideActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -45,7 +46,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onChannelOverrideCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -96,7 +97,7 @@ public void onChannelOverrideCreate(@NonNull GuildAuditLogEntryCreateEvent event @Override public void onChannelOverrideUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -143,7 +144,7 @@ public void onChannelOverrideUpdate(@NonNull GuildAuditLogEntryCreateEvent event @Override public void onChannelOverrideDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java index 797a2fc..a17b8fb 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -21,19 +21,20 @@ @SuppressWarnings("java:S1192") public final class EmojiActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public EmojiActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public EmojiActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -41,7 +42,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onEmojiCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -76,7 +77,7 @@ public void onEmojiCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onEmojiUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -112,7 +113,7 @@ public void onEmojiUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onEmojiDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java index 9bebbff..5a363cb 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java @@ -4,8 +4,8 @@ import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.GuildUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,19 +24,20 @@ @SuppressWarnings("java:S1192") public final class GuildUpdateActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildUpdateActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -44,7 +45,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onGuildUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -150,7 +151,7 @@ public void onGuildUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onGuildProfileUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java index 210a557..b45d719 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -21,19 +21,20 @@ @SuppressWarnings("java:S1192") public final class HomeSettingsActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public HomeSettingsActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public HomeSettingsActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -41,7 +42,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onHomeSettingsCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -68,7 +69,7 @@ public void onHomeSettingsCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onHomeSettingsUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java index deb19d8..911a4f7 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -21,19 +21,20 @@ @SuppressWarnings("java:S1192") public final class IntegrationActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public IntegrationActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public IntegrationActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -41,7 +42,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onIntegrationCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -81,7 +82,7 @@ public void onIntegrationUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { log.warn("Integration Update Event Detected. Implement this sometime later\n{}", event.getEntry().getChanges()); String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -103,7 +104,7 @@ public void onIntegrationUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onIntegrationDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -139,7 +140,7 @@ public void onIntegrationDelete(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onApplicationCommandPrivilegesUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java index a337115..1f17dcf 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java @@ -4,8 +4,8 @@ import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.InviteUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,19 +24,20 @@ @SuppressWarnings("java:S1192") public final class InviteActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public InviteActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public InviteActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -44,7 +45,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onInviteCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -106,7 +107,7 @@ public void onInviteUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { log.warn("Invite Update Event Detected. Implement this sometime later\n{}", event.getEntry().getChanges()); String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -129,7 +130,7 @@ public void onInviteUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onInviteDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java index f11a3e5..7d94638 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java @@ -4,8 +4,8 @@ import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.MemberUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,19 +24,20 @@ @SuppressWarnings("java:S1192") public final class MemberUpdateActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MemberUpdateActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MemberUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::memberEventChannelId) + .orElse(null); } @@ -44,7 +45,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onMemberUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -107,7 +108,7 @@ public void onMemberUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onMemberRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -155,7 +156,7 @@ public void onMemberRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { public void onMemberVoiceKick(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -178,7 +179,7 @@ public void onMemberVoiceKick(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onMemberVoiceMove(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java index 1571534..75f3460 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -21,19 +21,20 @@ @SuppressWarnings("java:S1192") public final class MessageActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MessageActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MessageActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::messageEventChannelId) + .orElse(null); } @@ -53,7 +54,7 @@ public void onMessageUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onMessageDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -74,7 +75,7 @@ public void onMessageDelete(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onMessageBulkDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java index 9388528..bcfd5f1 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.MessageUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class MessagePinActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MessagePinActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MessagePinActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onMessagePin(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -73,7 +74,7 @@ public void onMessagePin(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onMessageUnpin(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java index 937b934..dabd030 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -21,19 +21,20 @@ @SuppressWarnings("java:S1192") public final class ModActionActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ModActionActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ModActionActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::memberEventChannelId) + .orElse(null); } @@ -41,7 +42,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onKick(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -73,7 +74,7 @@ public void onKick(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onBan(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -104,7 +105,7 @@ public void onBan(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onUnban(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -132,7 +133,7 @@ public void onUnban(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onBotAdd(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -161,7 +162,7 @@ public void onPrune(@NonNull GuildAuditLogEntryCreateEvent event) { log.warn("Prune Event Detected\n{}", event.getEntry().getChanges()); String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java index 5c6a182..ae4d1f9 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.OnboardingUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,19 +24,20 @@ @SuppressWarnings("java:S1192") public final class OnboardingActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public OnboardingActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public OnboardingActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -46,7 +47,7 @@ public void onOnboardingCreate(@NonNull GuildAuditLogEntryCreateEvent event) { log.warn("Onboarding Create Event Detected. Implement this sometime later\n{}", event.getEntry().getChanges()); String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -69,7 +70,7 @@ public void onOnboardingCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onOnboardingUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java index cfd324c..b15a3f1 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class OnboardingPromptActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public OnboardingPromptActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public OnboardingPromptActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onOnboardingPromptCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -96,7 +97,7 @@ public void onOnboardingPromptCreate(@NonNull GuildAuditLogEntryCreateEvent even @Override public void onOnboardingPromptUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -158,7 +159,7 @@ public void onOnboardingPromptUpdate(@NonNull GuildAuditLogEntryCreateEvent even @Override public void onOnboardingPromptDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java index 1291576..9fed180 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.RoleUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -15,7 +15,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -24,19 +24,20 @@ @SuppressWarnings("java:S1192") public final class RoleActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public RoleActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public RoleActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -44,7 +45,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onRoleCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -95,7 +96,7 @@ public void onRoleCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -173,7 +174,7 @@ public void onRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onRoleDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java index a2ab041..7c2b2da 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.ScheduledEventUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class ScheduledEventActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ScheduledEventActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ScheduledEventActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onScheduledEventCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -90,7 +91,7 @@ public void onScheduledEventCreate(@NonNull GuildAuditLogEntryCreateEvent event) @Override public void onScheduledEventUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -170,7 +171,7 @@ public void onScheduledEventUpdate(@NonNull GuildAuditLogEntryCreateEvent event) @Override public void onScheduledEventDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java index 7a1307f..dbbc791 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.SoundboardUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class SoundboardActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public SoundboardActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public SoundboardActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onSoundboardSoundCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -89,7 +90,7 @@ public void onSoundboardSoundCreate(@NonNull GuildAuditLogEntryCreateEvent event @Override public void onSoundboardSoundUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -145,7 +146,7 @@ public void onSoundboardSoundUpdate(@NonNull GuildAuditLogEntryCreateEvent event @Override public void onSoundboardSoundDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java index 81f3df8..41a5bf8 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.StageUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class StageInstanceActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public StageInstanceActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public StageInstanceActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onStageInstanceCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -80,7 +81,7 @@ public void onStageInstanceCreate(@NonNull GuildAuditLogEntryCreateEvent event) @Override public void onStageInstanceUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -124,7 +125,7 @@ public void onStageInstanceUpdate(@NonNull GuildAuditLogEntryCreateEvent event) @Override public void onStageInstanceDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java index e93f169..34a3305 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.StickerUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -14,7 +14,7 @@ import net.dv8tion.jda.api.entities.sticker.GuildSticker; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -23,19 +23,20 @@ @SuppressWarnings("java:S1192") public final class StickerActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public StickerActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public StickerActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -43,7 +44,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onStickerCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -91,7 +92,7 @@ public void onStickerCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onStickerUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -145,7 +146,7 @@ public void onStickerUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onStickerDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java index ecf4510..b1abc8a 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java @@ -5,8 +5,8 @@ import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.ChannelUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.ThreadUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -17,7 +17,7 @@ import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -26,19 +26,20 @@ @SuppressWarnings("java:S1192") public final class ThreadActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ThreadActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ThreadActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -46,7 +47,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onThreadCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -106,7 +107,7 @@ public void onThreadCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onThreadUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -184,7 +185,7 @@ public void onThreadUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onThreadDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java index 67428a2..70ad89a 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -12,7 +12,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class UnknownActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public UnknownActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public UnknownActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -43,7 +44,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { public void onUnknownActionType(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java index 96f21de..2461727 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java @@ -1,8 +1,8 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -13,7 +13,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -22,19 +22,20 @@ @SuppressWarnings("java:S1192") public final class VoiceChannelStatusActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public VoiceChannelStatusActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public VoiceChannelStatusActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -42,7 +43,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onVoiceChannelStatusUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -77,7 +78,7 @@ public void onVoiceChannelStatusUpdate(@NonNull GuildAuditLogEntryCreateEvent ev @Override public void onVoiceChannelStatusDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java index 53b7700..dda9dce 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.GuildUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.WebhookUtils; -import io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -14,7 +14,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; @@ -23,19 +23,20 @@ @SuppressWarnings("java:S1192") public final class WebhookActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { - private final @NonNull AuditLogRegistrationClient client; + private final @NonNull PaperTrailGuildClient client; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public WebhookActionTypeHandler(@NonNull AuditLogRegistrationClient client, @NonNull EmbedCheckingService embedCheckingService) { + public WebhookActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; this.embedCheckingService = embedCheckingService; } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return client.getRegisteredGuild(guildId) - .map(AuditLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return client.getGuild(guildId) + .map(PaperTrailGuild::guildEventChannelId) + .orElse(null); } @@ -43,7 +44,7 @@ private String getRegisteredChannelId(@NonNull String guildId) { @Override public void onWebhookCreate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -86,7 +87,7 @@ public void onWebhookCreate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onWebhookUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); @@ -143,7 +144,7 @@ public void onWebhookUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { @Override public void onWebhookDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) return; + if (channelIdToSendTo == null) return; AuditLogEntry ale = event.getEntry(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java index 33a62bd..18d7a66 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java @@ -2,10 +2,10 @@ import com.google.common.base.Splitter; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; -import io.github.eggy03.papertrail.sdk.client.MessageLogContentClient; -import io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient; -import io.github.eggy03.papertrail.sdk.entity.MessageLogContentEntity; -import io.github.eggy03.papertrail.sdk.entity.MessageLogRegistrationEntity; +import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import io.github.eggy03.papertrail.http.client.PaperTrailMessageClient; +import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; +import io.github.eggy03.papertrail.http.entity.PaperTrailMessage; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -16,7 +16,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageUpdateEvent; import net.dv8tion.jda.api.utils.MarkdownUtil; -import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.time.Instant; @@ -27,52 +27,51 @@ @Slf4j public final class GuildMessageEventHandler { - private final @NonNull MessageLogRegistrationClient registrationClient; - private final @NonNull MessageLogContentClient contentClient; + private final @NonNull PaperTrailGuildClient paperTrailGuildClient; + private final @NonNull PaperTrailMessageClient paperTrailMessageClient; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildMessageEventHandler(@NonNull MessageLogRegistrationClient registrationClient, @NonNull MessageLogContentClient contentClient, @NonNull EmbedCheckingService embedCheckingService) { - this.registrationClient = registrationClient; - this.contentClient = contentClient; + public GuildMessageEventHandler(@NonNull PaperTrailGuildClient paperTrailGuildClient, @NonNull PaperTrailMessageClient paperTrailMessageClient, @NonNull EmbedCheckingService embedCheckingService) { + this.paperTrailGuildClient = paperTrailGuildClient; + this.paperTrailMessageClient = paperTrailMessageClient; this.embedCheckingService = embedCheckingService; } private boolean isGuildRegistered(@NonNull String guildId) { - return registrationClient.getRegisteredGuild(guildId).isPresent(); + return paperTrailGuildClient.getGuild(guildId).isPresent(); } - @NonNull + @Nullable private String getRegisteredChannelId(@NonNull String guildId) { - return registrationClient.getRegisteredGuild(guildId) - .map(MessageLogRegistrationEntity::getChannelId).orElse(StringUtils.EMPTY); + return paperTrailGuildClient.getGuild(guildId) + .map(PaperTrailGuild::messageEventChannelId) + .orElse(null); } public void handleMessageReceivedEvent(@NonNull MessageReceivedEvent event) { - if (!isGuildRegistered(event.getGuild().getId())) - return; + if (!isGuildRegistered(event.getGuild().getId())) return; String messageId = event.getMessageId(); String messageContent = event.getMessage().getContentDisplay(); String authorId = event.getAuthor().getId(); - contentClient.logMessage(messageId, messageContent, authorId); + paperTrailMessageClient.saveMessage(messageId, messageContent, authorId); } public void handleMessageUpdateEvent(@NonNull MessageUpdateEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) - return; + if (channelIdToSendTo == null) return; // fetch the old message object from the API - Optional oldMessageContentOptional = contentClient.retrieveMessage(event.getMessageId()); + Optional oldMessageContentOptional = paperTrailMessageClient.getMessage(event.getMessageId()); if (oldMessageContentOptional.isEmpty()) return; - MessageLogContentEntity oldMessageContentEntity = oldMessageContentOptional.get(); + PaperTrailMessage oldMessageContentEntity = oldMessageContentOptional.get(); // Fetch the old message - String oldMessage = oldMessageContentEntity.getMessageContent(); + String oldMessage = oldMessageContentEntity.messageContent(); // fetch the updated message and its author from the event String updatedMessage = event.getMessage().getContentDisplay(); String updatedMessageAuthor = event.getAuthor().getAsMention(); @@ -99,25 +98,23 @@ public void handleMessageUpdateEvent(@NonNull MessageUpdateEvent event) { eb.setTimestamp(Instant.now()); // update the database with the new message - contentClient.updateMessage(event.getMessageId(), updatedMessage, event.getAuthor().getId()); + paperTrailMessageClient.updateMessage(event.getMessageId(), updatedMessage, event.getAuthor().getId()); embedCheckingService.checkAndSend(event, eb, channelIdToSendTo); } public void handleMessageDeleteEvent(@NonNull MessageDeleteEvent event) { String channelIdToSendTo = getRegisteredChannelId(event.getGuild().getId()); - if (channelIdToSendTo.isBlank()) - return; + if (channelIdToSendTo == null) return; // fetch the message object from the API which was just deleted - Optional deletedMessageContentOptional = contentClient.retrieveMessage(event.getMessageId()); - if (deletedMessageContentOptional.isEmpty()) - return; + Optional deletedMessageContentOptional = paperTrailMessageClient.getMessage(event.getMessageId()); + if (deletedMessageContentOptional.isEmpty()) return; - MessageLogContentEntity deletedMessageContentEntity = deletedMessageContentOptional.get(); + PaperTrailMessage deletedMessageContentEntity = deletedMessageContentOptional.get(); // Fetch the deleted message and it's author id - String deletedMessage = deletedMessageContentEntity.getMessageContent(); - String deletedMessageAuthorId = deletedMessageContentEntity.getAuthorId(); + String deletedMessage = deletedMessageContentEntity.messageContent(); + String deletedMessageAuthorId = deletedMessageContentEntity.authorId(); User author = event.getJDA().getUserById(deletedMessageAuthorId); String mentionableAuthor = (author != null ? author.getAsMention() : deletedMessageAuthorId); @@ -136,7 +133,7 @@ public void handleMessageDeleteEvent(@NonNull MessageDeleteEvent event) { eb.setTimestamp(Instant.now()); // delete the message from the database - contentClient.deleteMessage(event.getMessageId()); + paperTrailMessageClient.deleteMessage(event.getMessageId()); embedCheckingService.checkAndSend(event, eb, channelIdToSendTo); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cd47bd8..c337786 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -17,6 +17,7 @@ quarkus.management.port=${MANAGEMENT_PORT:9000} # Logging Level quarkus.log.level=${GLOBAL_LOG_LEVEL:INFO} quarkus.log.category."io.github.eggy03.papertrail.bot".level=${APPLICATION_LOG_LEVEL:INFO} +quarkus.log.category."io.github.eggy03.papertrail.http".level=${APPLICATION_LOG_LEVEL:DEBUG} # Analytics quarkus.analytics.disabled=true From 8a2af8b7b4d591c05e2858879c2198914b4b9294 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 08:48:12 +0530 Subject: [PATCH 03/17] refactor: set base package log level to include client packages as well Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- src/main/resources/application.properties | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c337786..5d69db4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,8 +16,7 @@ quarkus.management.port=${MANAGEMENT_PORT:9000} # Logging Level quarkus.log.level=${GLOBAL_LOG_LEVEL:INFO} -quarkus.log.category."io.github.eggy03.papertrail.bot".level=${APPLICATION_LOG_LEVEL:INFO} -quarkus.log.category."io.github.eggy03.papertrail.http".level=${APPLICATION_LOG_LEVEL:DEBUG} +quarkus.log.category."io.github.eggy03.papertrail".level=${APPLICATION_LOG_LEVEL:INFO} # Analytics quarkus.analytics.disabled=true From 5226bc5dfe1ad419fa45be465d3c69b5862aedc5 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 09:17:18 +0530 Subject: [PATCH 04/17] refactor: change @Singleton to @ApplicationScoped Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../bot/listeners/command/ConfigCommandListener.java | 4 ++-- .../bot/listeners/command/DebugCommandListener.java | 4 ++-- .../bot/listeners/command/HelpCommandListener.java | 4 ++-- .../listeners/command/ServerStatCommandListener.java | 4 ++-- .../bot/listeners/guild/GuildBoostEventListener.java | 4 ++-- .../bot/listeners/guild/GuildMemberEventListener.java | 4 ++-- .../bot/listeners/guild/GuildPollEventListener.java | 4 ++-- .../guild/GuildSecurityIncidentEventListener.java | 4 ++-- .../bot/listeners/guild/GuildVoiceEventListener.java | 4 ++-- .../auditlog/GuildAuditLogEntryEventListener.java | 4 ++-- .../guild/message/GuildMessageEventListener.java | 4 ++-- .../bot/listeners/misc/ActivityUpdateListener.java | 4 ++-- .../bot/listeners/misc/SelfKickListener.java | 10 +++++----- .../misc/SlashCommandRegistrationListener.java | 4 ++-- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java index 55c34e5..c8a39bc 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ConfigCommandListener.java @@ -2,15 +2,15 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.command.ConfigCommandHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped public final class ConfigCommandListener extends ListenerAdapter { private final @NonNull ConfigCommandHandler handler; diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java index db3ab87..2303e19 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/DebugCommandListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.command.DebugCommandHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.entities.Guild; @@ -14,7 +14,7 @@ import java.util.concurrent.ThreadFactory; @Slf4j -@Singleton +@ApplicationScoped public final class DebugCommandListener extends ListenerAdapter { private final @NonNull DebugCommandHandler handler; diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java index 86940c9..3428ac8 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java @@ -2,15 +2,15 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.command.HelpCommandHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped public final class HelpCommandListener extends ListenerAdapter { private final @NonNull HelpCommandHandler handler; diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java index d1b45e7..e543681 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/ServerStatCommandListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.command.ServerStatCommandHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.entities.Guild; @@ -12,7 +12,7 @@ import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped @Slf4j public final class ServerStatCommandListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java index eb1fa7f..db617c7 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildBoostEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.GuildBoostEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateBoostTimeEvent; @@ -13,7 +13,7 @@ import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped @Slf4j public final class GuildBoostEventListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java index 69aeaac..20a39de 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildMemberEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.GuildMemberEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; @@ -14,7 +14,7 @@ // this event is not properly logged in the audit logs, hence the usage of JDA's listener is preferred // this event is logged in the same channel where the audit log events are logged -@Singleton +@ApplicationScoped @Slf4j public final class GuildMemberEventListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java index ac67bb9..f7b58fc 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildPollEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.GuildPollEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; @@ -12,7 +12,7 @@ import java.util.concurrent.ThreadFactory; // guild poll events are mapped to audit log table -@Singleton +@ApplicationScoped @Slf4j public final class GuildPollEventListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java index 6edd7e4..f7a2a4e 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildSecurityIncidentEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.GuildSecurityIncidentEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.guild.update.GuildUpdateSecurityIncidentActionsEvent; @@ -12,7 +12,7 @@ import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped @Slf4j public final class GuildSecurityIncidentEventListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java index 2a19e55..6197371 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/GuildVoiceEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.GuildVoiceEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; @@ -13,7 +13,7 @@ // this event is not properly logged in the audit logs, hence the usage of JDA's listener is preferred // this event is logged in the same channel where the audit log events are logged -@Singleton +@ApplicationScoped @Slf4j public final class GuildVoiceEventListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java index 69200cc..58821ce 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/auditlog/GuildAuditLogEntryEventListener.java @@ -2,9 +2,9 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog.AbstractGuildAuditLogEntryCreateEventActionTypeHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Instance; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; @@ -30,7 +30,7 @@ *

*/ @Slf4j -@Singleton +@ApplicationScoped public final class GuildAuditLogEntryEventListener extends ListenerAdapter { private final @NonNull Instance handlerInstances; diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java index 8ac055d..977c4d4 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/guild/message/GuildMessageEventListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.bot.service.handlers.guild.message.GuildMessageEventHandler; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import net.dv8tion.jda.api.events.message.MessageDeleteEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; @@ -12,7 +12,7 @@ import java.util.concurrent.ThreadFactory; -@Singleton +@ApplicationScoped public final class GuildMessageEventListener extends ListenerAdapter { private final @NonNull GuildMessageEventHandler handler; diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java index 05a7968..583c778 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java @@ -3,8 +3,8 @@ import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; import io.quarkus.runtime.ImageMode; import io.quarkus.runtime.LaunchMode; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.dv8tion.jda.api.entities.Activity; @@ -14,7 +14,7 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.sharding.ShardManager; -@Singleton +@ApplicationScoped @Slf4j public final class ActivityUpdateListener extends ListenerAdapter { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java index 44786aa..cb1bf83 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SelfKickListener.java @@ -2,8 +2,8 @@ import io.github.eggy03.papertrail.bot.annotations.VirtualThreadFactory; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.inject.Singleton; import lombok.NonNull; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.events.guild.GuildLeaveEvent; @@ -14,7 +14,7 @@ /* * This class will have methods that unregister the log channels from the database after the bot has been kicked */ -@Singleton +@ApplicationScoped public final class SelfKickListener extends ListenerAdapter { @NonNull @@ -32,9 +32,9 @@ public SelfKickListener(@NonNull PaperTrailGuildClient paperTrailGuildClient, @N public void onGuildLeave(@NonNull GuildLeaveEvent event) { Guild leftGuild = event.getGuild(); - virtualThreadFactory.newThread(() -> { - paperTrailGuildClient.deleteGuild(leftGuild.getId()); - }).start(); + virtualThreadFactory.newThread(() -> + paperTrailGuildClient.deleteGuild(leftGuild.getId()) + ).start(); } } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java index 3bdaaca..6c99f47 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/SlashCommandRegistrationListener.java @@ -1,6 +1,6 @@ package io.github.eggy03.papertrail.bot.listeners.misc; -import jakarta.inject.Singleton; +import jakarta.enterprise.context.ApplicationScoped; import lombok.NonNull; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.events.session.ReadyEvent; @@ -15,7 +15,7 @@ /* * Registers all the slash commands places throughout the code on startup */ -@Singleton +@ApplicationScoped public final class SlashCommandRegistrationListener extends ListenerAdapter { @Override From ad50182bb5a90172efbaa0ba0d2ff3384df0f568 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 09:39:58 +0530 Subject: [PATCH 05/17] refactor: rename PaperTrailConfig to PaperTrailEnvironment and move it to a new package Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../eggy03/papertrail/bot/BootstrapService.java | 10 +++++----- .../bot/configuration/RetrofitBeanProducer.java | 5 +++-- .../PaperTrailEnvironment.java} | 17 +++++++++++++++-- .../listeners/misc/ActivityUpdateListener.java | 10 +++++----- .../handlers/command/DebugCommandHandler.java | 10 +++++----- .../handlers/command/HelpCommandHandler.java | 14 +++++++------- src/main/resources/application.properties | 4 ++++ 7 files changed, 44 insertions(+), 26 deletions(-) rename src/main/java/io/github/eggy03/papertrail/bot/{configuration/PaperTrailConfig.java => environment/PaperTrailEnvironment.java} (63%) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java b/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java index 5bd5155..77fd21e 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/BootstrapService.java @@ -1,6 +1,6 @@ package io.github.eggy03.papertrail.bot; -import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.quarkus.runtime.Startup; import jakarta.annotation.PreDestroy; import jakarta.enterprise.context.ApplicationScoped; @@ -23,13 +23,13 @@ @Startup public final class BootstrapService { - private final @NonNull PaperTrailConfig paperTrailConfig; + private final @NonNull PaperTrailEnvironment paperTrailEnvironment; private final @NonNull Instance listeners; private final @NonNull ShardManager shardManager; @Inject - public BootstrapService(@NonNull PaperTrailConfig paperTrailConfig, @NonNull Instance listeners) { - this.paperTrailConfig = paperTrailConfig; + public BootstrapService(@NonNull PaperTrailEnvironment paperTrailEnvironment, @NonNull Instance listeners) { + this.paperTrailEnvironment = paperTrailEnvironment; this.listeners = listeners; this.shardManager = constructShardManager(); } @@ -37,7 +37,7 @@ public BootstrapService(@NonNull PaperTrailConfig paperTrailConfig, @NonNull Ins @NonNull ShardManager constructShardManager() { - DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.createDefault(paperTrailConfig.discord().token()); + DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.createDefault(paperTrailEnvironment.discord().token()); builder.enableIntents(GatewayIntent.SCHEDULED_EVENTS, GatewayIntent.AUTO_MODERATION_EXECUTION, diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java b/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java index ac2f392..7476f91 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/configuration/RetrofitBeanProducer.java @@ -1,6 +1,7 @@ package io.github.eggy03.papertrail.bot.configuration; import com.fasterxml.jackson.databind.ObjectMapper; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; @@ -19,8 +20,8 @@ public final class RetrofitBeanProducer { private final @NonNull ObjectMapper objectMapper; @Inject - public RetrofitBeanProducer(@NonNull PaperTrailConfig paperTrailConfig, @NonNull ObjectMapper objectMapper) { - this.apiUrl = paperTrailConfig.api().url(); + public RetrofitBeanProducer(@NonNull PaperTrailEnvironment paperTrailEnvironment, @NonNull ObjectMapper objectMapper) { + this.apiUrl = paperTrailEnvironment.api().url(); this.objectMapper = objectMapper; } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java b/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java similarity index 63% rename from src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java rename to src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java index 91aad7f..3b40808 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/configuration/PaperTrailConfig.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java @@ -1,14 +1,15 @@ -package io.github.eggy03.papertrail.bot.configuration; +package io.github.eggy03.papertrail.bot.environment; import io.smallrye.config.ConfigMapping; import io.smallrye.config.WithName; import lombok.NonNull; @ConfigMapping(prefix = "papertrail") -public interface PaperTrailConfig { +public interface PaperTrailEnvironment { General general(); + EmbedColor embedColor(); Discord discord(); API api(); @@ -29,6 +30,18 @@ interface General { } + interface EmbedColor { + + @WithName("success.color.integer") + int successColor(); + + @WithName("warning.color.integer") + int warningColor(); + + @WithName("destructive.color.integer") + int destructiveColor(); + } + interface Discord { @WithName("token") diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java index 583c778..62ae1c6 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java @@ -1,6 +1,6 @@ package io.github.eggy03.papertrail.bot.listeners.misc; -import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.quarkus.runtime.ImageMode; import io.quarkus.runtime.LaunchMode; import jakarta.enterprise.context.ApplicationScoped; @@ -19,18 +19,18 @@ public final class ActivityUpdateListener extends ListenerAdapter { private final @NonNull ShardManager manager; - private final @NonNull PaperTrailConfig paperTrailConfig; + private final @NonNull PaperTrailEnvironment paperTrailEnvironment; @Inject - public ActivityUpdateListener(@NonNull ShardManager manager, @NonNull PaperTrailConfig paperTrailConfig) { + public ActivityUpdateListener(@NonNull ShardManager manager, @NonNull PaperTrailEnvironment paperTrailEnvironment) { this.manager = manager; - this.paperTrailConfig = paperTrailConfig; + this.paperTrailEnvironment = paperTrailEnvironment; } @Override public void onReady(@NonNull ReadyEvent event) { // update on cold start manager.setActivity(Activity.customStatus( - "/setup | " + paperTrailConfig.general().appVersion() + " | " + getImageMode() + " | " + getLaunchMode()) + "/setup | " + paperTrailEnvironment.general().appVersion() + " | " + getImageMode() + " | " + getLaunchMode()) ); } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java index 4176331..b6d0b69 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/DebugCommandHandler.java @@ -1,6 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.command; -import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.PermissionUtils; import jakarta.enterprise.context.ApplicationScoped; @@ -22,11 +22,11 @@ @ApplicationScoped public final class DebugCommandHandler { - private final @NonNull PaperTrailConfig paperTrailConfig; + private final @NonNull PaperTrailEnvironment paperTrailEnvironment; @Inject - public DebugCommandHandler(@NonNull PaperTrailConfig paperTrailConfig) { - this.paperTrailConfig = paperTrailConfig; + public DebugCommandHandler(@NonNull PaperTrailEnvironment paperTrailEnvironment) { + this.paperTrailEnvironment = paperTrailEnvironment; } public void sendDebugInfo(@NonNull SlashCommandInteractionEvent event, @NonNull Guild guild, @NonNull Member member) { @@ -48,7 +48,7 @@ public void sendDebugInfo(@NonNull SlashCommandInteractionEvent event, @NonNull eb.addBlankField(true); eb.addField(MarkdownUtil.underline("Bot Info"), MarkdownUtil.quoteBlock(getBotInfo(event)), true); - eb.setFooter(paperTrailConfig.general().appName() + " " + paperTrailConfig.general().appVersion()); + eb.setFooter(paperTrailEnvironment.general().appName() + " " + paperTrailEnvironment.general().appVersion()); eb.setTimestamp(Instant.now()); event.getHook().editOriginalEmbeds(eb.build()).queue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java index fb877cf..fb913cb 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java @@ -1,6 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.command; -import io.github.eggy03.papertrail.bot.configuration.PaperTrailConfig; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -14,18 +14,18 @@ @ApplicationScoped public final class HelpCommandHandler { - private final @NonNull PaperTrailConfig paperTrailConfig; + private final @NonNull PaperTrailEnvironment paperTrailEnvironment; @Inject - public HelpCommandHandler(@NonNull PaperTrailConfig paperTrailConfig) { - this.paperTrailConfig = paperTrailConfig; + public HelpCommandHandler(@NonNull PaperTrailEnvironment paperTrailEnvironment) { + this.paperTrailEnvironment = paperTrailEnvironment; } public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("🛠️ Setup Guide for " + paperTrailConfig.general().appName()); + eb.setTitle("🛠️ Setup Guide for " + paperTrailEnvironment.general().appName()); eb.setDescription("Configure PaperTrailBot to receive different types of server events in separate channels."); eb.setColor(Color.decode("#38e8bc")); @@ -86,8 +86,8 @@ public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { "Use `/stats` to **view useful server information**.", false); - eb.addField("📬 Need help?", "Create an issue on [GitHub](" + paperTrailConfig.general().githubIssueLink() + ")", false); - eb.setFooter(paperTrailConfig.general().appName() + " " + paperTrailConfig.general().appVersion()); + eb.addField("📬 Need help?", "Create an issue on [GitHub](" + paperTrailEnvironment.general().githubIssueLink() + ")", false); + eb.setFooter(paperTrailEnvironment.general().appName() + " " + paperTrailEnvironment.general().appVersion()); eb.setTimestamp(Instant.now()); MessageEmbed mb = eb.build(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5d69db4..7984347 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,6 +8,10 @@ papertrail.discord.token=${TOKEN} # PaperTrail API URL papertrail.api.url=${API_URL} +# Embed Color Config +papertrail.embed-color.success.color.integer=${EMBED_SUCCESS_COLOR_INT:712458} +papertrail.embed-color.warning.color.integer=${EMBED_WARNING_COLOR_INT:16776960} +papertrail.embed-color.destructive.color.integer=${EMBED_DESTRUCTIVE_COLOR_INT:16711680} #Port quarkus.http.port=${PORT:8080} From ba7068faeb790cc97f9e983249592982a2dbb21c Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 09:44:28 +0530 Subject: [PATCH 06/17] fix: help command detects for /help and not /status Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../bot/listeners/command/HelpCommandListener.java | 2 +- .../bot/service/handlers/command/HelpCommandHandler.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java index 3428ac8..c5d90f3 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/command/HelpCommandListener.java @@ -25,7 +25,7 @@ public HelpCommandListener(@NonNull HelpCommandHandler handler, @NonNull @Virtua @Override public void onSlashCommandInteraction(@NonNull SlashCommandInteractionEvent event) { - if (event.getName().equals("setup")) { + if (event.getName().equals("help")) { virtualThreadFactory .newThread(() -> handler.sendInstructions(event)) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java index fb913cb..5a65099 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java @@ -25,7 +25,7 @@ public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { EmbedBuilder eb = new EmbedBuilder(); - eb.setTitle("🛠️ Setup Guide for " + paperTrailEnvironment.general().appName()); + eb.setTitle("Setup Guide for " + paperTrailEnvironment.general().appName()); eb.setDescription("Configure PaperTrailBot to receive different types of server events in separate channels."); eb.setColor(Color.decode("#38e8bc")); @@ -73,7 +73,7 @@ public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { ); eb.addField( - "🔒 Permissions", + "Permissions", "Setup configuration commands require the **Administrator** permission.", false ); @@ -86,7 +86,7 @@ public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { "Use `/stats` to **view useful server information**.", false); - eb.addField("📬 Need help?", "Create an issue on [GitHub](" + paperTrailEnvironment.general().githubIssueLink() + ")", false); + eb.addField("Need help?", "Create an issue on [GitHub](" + paperTrailEnvironment.general().githubIssueLink() + ")", false); eb.setFooter(paperTrailEnvironment.general().appName() + " " + paperTrailEnvironment.general().appVersion()); eb.setTimestamp(Instant.now()); From 3bf3f3fedae93ddc600e487e6a8d7dcf39208648 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:04:58 +0530 Subject: [PATCH 07/17] refactor: make the help guide easier to read Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../handlers/command/HelpCommandHandler.java | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java index 5a65099..71dc360 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/HelpCommandHandler.java @@ -7,6 +7,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.utils.MarkdownUtil; import java.awt.Color; import java.time.Instant; @@ -26,65 +27,71 @@ public void sendInstructions(@NonNull SlashCommandInteractionEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Setup Guide for " + paperTrailEnvironment.general().appName()); - eb.setDescription("Configure PaperTrailBot to receive different types of server events in separate channels."); - eb.setColor(Color.decode("#38e8bc")); + eb.setColor(Color.WHITE); - eb.addField("Initial Setup", - "Use `/setup save` to save your server configuration. You can provide one or more event channels during setup.", + eb.addField( + MarkdownUtil.underline("1. Initial Setup"), + "Use `/config save [guild_event_channel] [member_event_channel] [message_event_chanel]` to save your server configuration. You can provide one or more event channels during setup.", false ); eb.addField( - "Guild Events", - "The **Guild Event Channel** receives events related to the server itself", + MarkdownUtil.quote("Guild Events"), + MarkdownUtil.quoteBlock("The `guild_event_channel` receives events related to the server itself."), false ); eb.addField( - "Member Events", - "The **Member Event Channel** receives events related to server members", + MarkdownUtil.quote("Member Events"), + MarkdownUtil.quoteBlock("The `member_event_channel` receives events related to server members."), false ); eb.addField( - "Message Events", - "The **Message Event Channel** receives message-related events and logs.", + MarkdownUtil.quote("Message Events"), + MarkdownUtil.quoteBlock("The `message_event_channel` receives message-related events and message logs."), false ); eb.addField( - "View Configuration", - "Use `/setup view` to **see the channels currently configured** ", + MarkdownUtil.underline("2. View Configuration"), + "Use `/config view` to see the channels currently configured ", false ); eb.addField( - "Update Configuration", - "Use `/setup update` to **update your event channel configuration**. " + MarkdownUtil.underline("3. Update Configuration"), + "Use `/config update [guild_event_channel] [member_event_channel] [message_event_chanel]` to **update** your event channel configuration. " + "Any channel option that is not provided will be **cleared** and set to no channel.", false ); eb.addField( - "Remove Configuration", - "Use `/setup update` without providing any event channels to " + MarkdownUtil.underline("4. Remove Configuration"), + "Use `/config update` without providing any event channels to " + "**remove the existing server configuration**.", false ); eb.addField( - "Permissions", - "Setup configuration commands require the **Administrator** permission.", + MarkdownUtil.quote("Permissions"), + MarkdownUtil.quoteBlock("Only users with the ADMINISTRATOR permission can use the `/config` command."), false ); eb.addBlankField(false); - eb.addBlankField(false); + eb.addField( + MarkdownUtil.underline("5. View Server Stats"), + "Use `/stats` to view useful server information.", + false + ); - eb.addField("View Server Stats", - "Use `/stats` to **view useful server information**.", - false); + eb.addField( + MarkdownUtil.underline("6. View Debug Information"), + "Use `/debug` to view useful information about the bot. This information may help troubleshoot issues related to the bot.", + false + ); eb.addField("Need help?", "Create an issue on [GitHub](" + paperTrailEnvironment.general().githubIssueLink() + ")", false); eb.setFooter(paperTrailEnvironment.general().appName() + " " + paperTrailEnvironment.general().appVersion()); From ce7c429c520991c58530b95b5858b43b92e3c2ba Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:36:36 +0530 Subject: [PATCH 08/17] feat: allow configurable embed colors Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../command/ConfigCommandHandler.java | 22 ++++++++++--------- .../command/ServerStatCommandHandler.java | 2 +- .../guild/GuildBoostEventHandler.java | 14 +++++++----- .../guild/GuildMemberEventHandler.java | 10 +++++---- .../handlers/guild/GuildPollEventHandler.java | 8 ++++--- .../GuildSecurityIncidentEventHandler.java | 22 ++++++++++--------- .../guild/GuildVoiceEventHandler.java | 12 +++++----- .../auditlog/AutoModActionTypeHandler.java | 21 +++++++++--------- .../auditlog/ChannelActionTypeHandler.java | 13 ++++++----- .../ChannelOverrideActionTypeHandler.java | 13 ++++++----- .../auditlog/EmojiActionTypeHandler.java | 13 ++++++----- .../GuildUpdateActionTypeHandler.java | 11 +++++----- .../HomeSettingsActionTypeHandler.java | 11 +++++----- .../IntegrationActionTypeHandler.java | 15 +++++++------ .../auditlog/InviteActionTypeHandler.java | 13 ++++++----- .../MemberUpdateActionTypeHandler.java | 19 ++++++++-------- .../auditlog/MessageActionTypeHandler.java | 11 +++++----- .../auditlog/MessagePinActionTypeHandler.java | 11 +++++----- .../auditlog/ModActionActionTypeHandler.java | 17 +++++++------- .../auditlog/OnboardingActionTypeHandler.java | 11 +++++----- .../OnboardingPromptActionTypeHandler.java | 13 ++++++----- .../guild/auditlog/RoleActionTypeHandler.java | 13 ++++++----- .../ScheduledEventActionTypeHandler.java | 13 ++++++----- .../auditlog/SoundboardActionTypeHandler.java | 13 ++++++----- .../StageInstanceActionTypeHandler.java | 13 ++++++----- .../auditlog/StickerActionTypeHandler.java | 13 ++++++----- .../auditlog/ThreadActionTypeHandler.java | 13 ++++++----- .../auditlog/UnknownActionTypeHandler.java | 9 ++++---- .../VoiceChannelStatusActionTypeHandler.java | 13 ++++++----- .../auditlog/WebhookActionTypeHandler.java | 13 ++++++----- .../message/GuildMessageEventHandler.java | 10 +++++---- 31 files changed, 221 insertions(+), 184 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java index 662d7b6..1236520 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ConfigCommandHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.command; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; import jakarta.enterprise.context.ApplicationScoped; @@ -13,7 +14,6 @@ import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.utils.MarkdownUtil; -import java.awt.Color; import java.util.Optional; @ApplicationScoped @@ -22,10 +22,12 @@ public final class ConfigCommandHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; @Inject - public ConfigCommandHandler(@NonNull PaperTrailGuildClient client) { + public ConfigCommandHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment) { this.client = client; + this.environment = environment; } public void saveGuild(@NonNull SlashCommandInteractionEvent event) { @@ -54,10 +56,10 @@ public void saveGuild(@NonNull SlashCommandInteractionEvent event) { eb.setTitle("Bot Setup Process"); if (success) { - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Setup Success"), MarkdownUtil.codeblock("Events will be logged in your set channels"), false); } else { - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Setup Failure"), MarkdownUtil.codeblock("Channels could not be registered. This could be due to an existing configuration. You must also provide at least one channel during setup."), false); } @@ -97,12 +99,12 @@ public void viewGuild(@NonNull SlashCommandInteractionEvent event) { String memberEventChannelJumpUrl = memberEventChannel == null ? "Not Available" : memberEventChannel.getJumpUrl(); String messageEventChannelJumpUrl = messageEventChannel == null ? "Not Available" : messageEventChannel.getJumpUrl(); - eb.setColor(Color.CYAN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Guild Event Channel"), guildEventChannelJumpUrl, false); eb.addField(MarkdownUtil.underline("Member Event Channel"), memberEventChannelJumpUrl, false); eb.addField(MarkdownUtil.underline("Message Event Channel"), messageEventChannelJumpUrl, false); }, () -> { - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Warning"), MarkdownUtil.codeblock("No Configuration Found"), false); }); @@ -132,10 +134,10 @@ public void updateGuild(@NonNull SlashCommandInteractionEvent event) { eb.setTitle("Delete Existing Configuration"); if (success) { - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().destructiveColor()); eb.addField(MarkdownUtil.underline("Deletion Success"), MarkdownUtil.codeblock("Configuration Deleted"), false); } else { - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Deletion Failure"), MarkdownUtil.codeblock("No Configuration Found."), false); } @@ -155,10 +157,10 @@ public void updateGuild(@NonNull SlashCommandInteractionEvent event) { eb.setTitle("Update Existing Configuration"); if (success) { - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Update Success"), MarkdownUtil.codeblock("Configuration Has Been Updated"), false); } else { - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Update Failure"), MarkdownUtil.codeblock("No Configuration Found."), false); } diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ServerStatCommandHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ServerStatCommandHandler.java index f16c2f4..816a37c 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ServerStatCommandHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/command/ServerStatCommandHandler.java @@ -25,7 +25,7 @@ public void sendServerStats(@NonNull SlashCommandInteractionEvent event, @NonNul eb.setTitle("Server Statistics"); eb.setDescription("Statistics For: " + guild.getName()); eb.setThumbnail(guild.getIconUrl()); - eb.setColor(Color.PINK); + eb.setColor(Color.WHITE); eb.addField(MarkdownUtil.underline("Guild Owner"), MarkdownUtil.quoteBlock(getGuildOwner(guild)), false); eb.addField(MarkdownUtil.underline("Guild Created On"), MarkdownUtil.quoteBlock(getGuildCreationDate(guild)), false); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java index dde3e84..2a0fd99 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildBoostEventHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -16,7 +17,6 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; import java.time.OffsetDateTime; @@ -25,11 +25,13 @@ public final class GuildBoostEventHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildBoostEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildBoostEventHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -51,7 +53,7 @@ public void handleUpdateBoostTier(@NonNull GuildUpdateBoostTierEvent event) { eb.setTitle("Audit Log Entry | Server Boost Tier Update"); eb.setDescription(MarkdownUtil.quoteBlock("Guild Boost Tier Updated\nTarget Guild: " + guild.getName())); eb.setThumbnail(guild.getIconUrl()); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); Guild.BoostTier oldBoostTier = event.getOldBoostTier(); Guild.BoostTier newBoostTier = event.getNewBoostTier(); @@ -85,7 +87,7 @@ public void handleUpdateBoostCount(@NonNull GuildUpdateBoostCountEvent event) { eb.setTitle("Audit Log Entry | Server Boost Event"); eb.setDescription(MarkdownUtil.quoteBlock("Guild Boost Count Updated\nTarget Guild: " + guild.getName())); eb.setThumbnail(guild.getIconUrl()); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Old Boost Count"), "╰┈➤" + event.getOldBoostCount(), false); eb.addField(MarkdownUtil.underline("New Boost Count"), "╰┈➤" + event.getNewBoostCount(), false); @@ -113,10 +115,10 @@ public void handleMemberUpdateBoostTime(@NonNull GuildMemberUpdateBoostTimeEvent if (newBoostTime != null) { eb.setDescription(MarkdownUtil.quoteBlock("Booster Gained: " + mentionableMember + "\nTarget Server: " + guild.getName())); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().successColor()); } else { eb.setDescription(MarkdownUtil.quoteBlock("Booster Lost: " + mentionableMember + "\nTarget Server: " + guild.getName())); - eb.setColor(Color.GRAY); + eb.setColor(environment.embedColor().destructiveColor()); } eb.setFooter(guild.getName()); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java index d1ba932..b74a59a 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildMemberEventHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -19,7 +20,6 @@ import net.dv8tion.jda.api.utils.TimeFormat; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; @ApplicationScoped @@ -27,11 +27,13 @@ public final class GuildMemberEventHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildMemberEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildMemberEventHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -54,7 +56,7 @@ public void handleGuildMemberJoin(@NonNull GuildMemberJoinEvent event) { eb.setTitle("Audit Log Entry | Member Join Event"); eb.setDescription(MarkdownUtil.quoteBlock("Member Joined: " + user.getName() + "\nGuild: " + guild.getName())); eb.setThumbnail(user.getEffectiveAvatarUrl()); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Member Name"), "╰┈➤" + user.getName(), false); eb.addField(MarkdownUtil.underline("Member Mention"), "╰┈➤" + user.getAsMention(), false); @@ -79,7 +81,7 @@ public void handleGuildMemberRemove(@NonNull GuildMemberRemoveEvent event) { eb.setTitle("Audit Log Entry | Member Leave Event"); eb.setDescription(MarkdownUtil.quoteBlock("Member Left: " + user.getName() + "\nGuild: " + guild.getName())); eb.setThumbnail(user.getEffectiveAvatarUrl()); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); eb.addField(MarkdownUtil.underline("Member Name"), "╰┈➤" + user.getName(), false); eb.addField(MarkdownUtil.underline("Member ID"), "╰┈➤" + user.getId(), false); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java index 6348e8e..8d7f102 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildPollEventHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,7 +16,6 @@ import net.dv8tion.jda.api.utils.TimeFormat; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; @ApplicationScoped @@ -23,11 +23,13 @@ public final class GuildPollEventHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildPollEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildPollEventHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -50,7 +52,7 @@ public void handlePollCreationEvent(@NonNull MessageReceivedEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Poll Creation Event"); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().successColor()); eb.setDescription(MarkdownUtil.quoteBlock("Poll Created By: " + event.getAuthor().getAsMention() + "\nTarget Channel: " + event.getChannel().getAsMention())); eb.addField(MarkdownUtil.underline("Question"), messagePoll.getQuestion().getText(), false); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java index 2f008a5..0502159 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildSecurityIncidentEventHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.DurationUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -16,7 +17,6 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; import java.time.OffsetDateTime; @@ -25,11 +25,13 @@ public final class GuildSecurityIncidentEventHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildSecurityIncidentEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildSecurityIncidentEventHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -58,7 +60,7 @@ public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecu EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Incident Resolved"); eb.setDescription(MarkdownUtil.quoteBlock("Incident Type: DM Spam\nStatus: Resolved")); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("DM Spam Started At"), DurationUtils.isoToLocalTimeCounter(oldDMSpamDetectedAt), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -70,7 +72,7 @@ public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecu EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Incident Detected"); eb.setDescription(MarkdownUtil.quoteBlock("Incident Type: DM Spam\nStatus: Detected")); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("DM Spam Detected At"), DurationUtils.isoToLocalTimeCounter(newDMSpamDetectedAt), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -82,7 +84,7 @@ public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecu EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Incident Resolved"); eb.setDescription(MarkdownUtil.quoteBlock("Incident Type: RAID\nStatus: Resolved")); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Raid Was Detected At"), DurationUtils.isoToLocalTimeCounter(oldRaidDetectedAt), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -94,7 +96,7 @@ public void handleGuildUpdateSecurityIncidentDetections(@NonNull GuildUpdateSecu EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Incident Detected"); eb.setDescription(MarkdownUtil.quoteBlock("Incident Type: RAID\nStatus: Detected")); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Raid Detected At"), DurationUtils.isoToLocalTimeCounter(newRaidDetectedAt), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -120,7 +122,7 @@ public void handleGuildUpdateSecurityIncidentActions(@NonNull GuildUpdateSecurit EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Action Disabled"); eb.setDescription(MarkdownUtil.quoteBlock("Action Type: DM Pause\nStatus: Disabled")); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("DMs Were Paused Until"), DurationUtils.isoToLocalTimeCounter(oldDMDisabledUntil), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -132,7 +134,7 @@ public void handleGuildUpdateSecurityIncidentActions(@NonNull GuildUpdateSecurit EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Action Enabled"); eb.setDescription(MarkdownUtil.quoteBlock("Action Type: DM Pause\nStatus: Enabled")); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("DMs Paused Until"), DurationUtils.isoToLocalTimeCounter(newDMDisabledUntil), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -144,7 +146,7 @@ public void handleGuildUpdateSecurityIncidentActions(@NonNull GuildUpdateSecurit EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Action Disabled"); eb.setDescription(MarkdownUtil.quoteBlock("Action Type: Invite Pause\nStatus: Disabled")); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Invites Were Paused Until"), DurationUtils.isoToLocalTimeCounter(oldInvitesPausedUntil), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); @@ -156,7 +158,7 @@ public void handleGuildUpdateSecurityIncidentActions(@NonNull GuildUpdateSecurit EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Security Action Enabled"); eb.setDescription(MarkdownUtil.quoteBlock("Action Type: Invite Pause\nStatus: Enabled")); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Invites Paused Until"), DurationUtils.isoToLocalTimeCounter(newInvitesPausedUntil), false); eb.setFooter(event.getGuild().getName()); eb.setTimestamp(Instant.now()); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java index cb790b8..f206e82 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/GuildVoiceEventHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,7 +15,6 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; @ApplicationScoped @@ -22,11 +22,13 @@ public final class GuildVoiceEventHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildVoiceEventHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildVoiceEventHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -52,7 +54,7 @@ public void handleVoiceUpdateEvent(@NonNull GuildVoiceUpdateEvent event) { if (left == null && joined != null) { // User has joined a vc eb.setDescription("A Member Has Joined A Voice Channel"); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField( MarkdownUtil.underline("Connection Event Metadata"), MarkdownUtil.quoteBlock("Connected Member: " + member.getAsMention() + "\nJoined Channel: " + joined.getAsMention()), @@ -63,7 +65,7 @@ public void handleVoiceUpdateEvent(@NonNull GuildVoiceUpdateEvent event) { if (left != null && joined != null) { // Moved from one channel to another eb.setDescription("A Member Has Switched Voice Channels"); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Switch Event Metadata"), MarkdownUtil.quoteBlock("Switched Member: " + member.getAsMention() + "\nLeft Channel: " + left.getAsMention() + "\nJoined Channel: " + joined.getAsMention()), @@ -73,7 +75,7 @@ public void handleVoiceUpdateEvent(@NonNull GuildVoiceUpdateEvent event) { if (left != null && joined == null) { // User disconnected voluntarily (or was disconnected by a moderator) eb.setDescription("A Member Has Left A Voice Channel"); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); eb.addField( MarkdownUtil.underline("Disconnection Event Metadata"), MarkdownUtil.quoteBlock("Disconnected Member: " + member.getAsMention() + "\nLeft Channel: " + left.getAsMention()), diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java index 7837f6f..789fa5b 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/AutoModActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.AutoModUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class AutoModActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public AutoModActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public AutoModActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -56,7 +57,7 @@ public void onAutoModerationFlagToChannel(@NonNull GuildAuditLogEntryCreateEvent String targetMention = (targetUser != null ? targetUser.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Event: AutoMod Message Flag\nTarget Member: " + targetMention)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Additional Info"), @@ -86,7 +87,7 @@ public void onAutoModerationMemberTimeout(@NonNull GuildAuditLogEntryCreateEvent String targetMention = (targetUser != null ? targetUser.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Event: AutoMod Member Timeout\nTarget Member: " + targetMention)); - eb.setColor(Color.MAGENTA); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Additional Info"), @@ -115,7 +116,7 @@ public void onAutoModerationRuleBlockMessage(@NonNull GuildAuditLogEntryCreateEv String targetMention = (targetUser != null ? targetUser.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Event: AutoMod Message Block\nTarget Member: " + targetMention)); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Additional Info"), @@ -145,7 +146,7 @@ public void onAutoModerationRuleCreate(@NonNull GuildAuditLogEntryCreateEvent ev String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getUserId()); eb.setDescription(MarkdownUtil.quoteBlock("Rule Created By: " + mentionableExecutor + "\nRule Created For: AutoMod")); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -192,7 +193,7 @@ public void onAutoModerationRuleUpdate(@NonNull GuildAuditLogEntryCreateEvent ev String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getUserId()); eb.setDescription(MarkdownUtil.quoteBlock("Rule Updated By: " + mentionableExecutor + "\nRule Updated For: AutoMod")); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); // add name of the rule which got updated AutoModRule rule = ale.getGuild().retrieveAutoModRuleById(ale.getTargetId()).complete(); @@ -221,7 +222,7 @@ public void onAutoModerationRuleDelete(@NonNull GuildAuditLogEntryCreateEvent ev String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getUserId()); eb.setDescription(MarkdownUtil.quoteBlock("Rule Deleted By: " + mentionableExecutor + "\nRule Deleted For: AutoMod")); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -253,7 +254,7 @@ public void onAutoModerationQuarantineUser(@NonNull GuildAuditLogEntryCreateEven String mentionableTarget = (targetMember != null ? targetMember.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Quarantined User: " + mentionableTarget)); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField("INFO", "PaperTrail is still learning about this event", false); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java index 3358991..7cc763c 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -18,19 +19,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class ChannelActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ChannelActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ChannelActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -60,7 +61,7 @@ public void onChannelCreate(@NonNull GuildAuditLogEntryCreateEvent event) { eb.setTitle("Audit Log Entry | Channel Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Channel Created By: " + mentionableExecutor + "\nTarget Channel: " + targetChannelMention)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -124,7 +125,7 @@ public void onChannelUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { eb.setTitle("Audit Log Entry | Channel Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Channel Updated By: " + mentionableExecutor + "\nTarget Channel: " + targetChannelMention)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -234,7 +235,7 @@ public void onChannelDelete(@NonNull GuildAuditLogEntryCreateEvent event) { eb.setTitle("Audit Log Entry | Channel Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Channel Deleted By: " + mentionableExecutor + "\nTarget Channel ID: " + ale.getTargetId())); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java index b8c7b65..cab1c30 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ChannelOverrideActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.ChannelUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -18,19 +19,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class ChannelOverrideActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ChannelOverrideActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ChannelOverrideActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -59,7 +60,7 @@ public void onChannelOverrideCreate(@NonNull GuildAuditLogEntryCreateEvent event EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Channel Override Create"); eb.setDescription(MarkdownUtil.quoteBlock("Override Created By: " + mentionableExecutor + "\nTarget Channel: " + targetChannelMention)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -110,7 +111,7 @@ public void onChannelOverrideUpdate(@NonNull GuildAuditLogEntryCreateEvent event EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Channel Override Update"); eb.setDescription(MarkdownUtil.quoteBlock("Override Updated By: " + mentionableExecutor + "\nTarget Channel: " + targetChannelMention)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Override Type"), "╰┈➤" + ChannelUtils.resolveChannelOverrideTargetType(ale.getOptionByName("type")), false); eb.addField(MarkdownUtil.underline("Permissions Overridden For"), "╰┈➤" + getTargetRoleOrMember(ale, event), false); @@ -158,7 +159,7 @@ public void onChannelOverrideDelete(@NonNull GuildAuditLogEntryCreateEvent event eb.setTitle("Audit Log Entry | Channel Override Delete"); eb.setDescription(MarkdownUtil.quoteBlock("Override Deleted By: " + mentionableExecutor + "\nTarget Channel: " + targetChannelMention)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java index a17b8fb..a257ed7 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/EmojiActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,19 +15,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class EmojiActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public EmojiActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public EmojiActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -52,7 +53,7 @@ public void onEmojiCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Emoji Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Emoji Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -88,7 +89,7 @@ public void onEmojiUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Emoji Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Emoji Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -123,7 +124,7 @@ public void onEmojiDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Emoji Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Emoji Deleted By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java index 5a363cb..ef3e8a6 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/GuildUpdateActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class GuildUpdateActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public GuildUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -55,7 +56,7 @@ public void onGuildUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Guild Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Guild Settings Updated By: " + mentionableExecutor + "\nTarget Guild: " + event.getGuild().getName())); - eb.setColor(Color.MAGENTA); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -161,7 +162,7 @@ public void onGuildProfileUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Guild Profile Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Guild Profile Updated By: " + mentionableExecutor + "\nTarget Guild: " + event.getGuild().getName())); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().keySet().forEach(key -> { switch (key) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java index b45d719..18956b7 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/HomeSettingsActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,19 +15,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class HomeSettingsActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public HomeSettingsActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public HomeSettingsActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -52,7 +53,7 @@ public void onHomeSettingsCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Server Guide Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Server Guide Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField( MarkdownUtil.underline("More Info"), @@ -79,7 +80,7 @@ public void onHomeSettingsUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Server Guide Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Server Guide Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().keySet().forEach(key -> { switch (key) { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java index 911a4f7..5f1af25 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/IntegrationActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,19 +15,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class IntegrationActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public IntegrationActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public IntegrationActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -52,7 +53,7 @@ public void onIntegrationCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Integration Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Integration Created By: " + mentionableExecutor)); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -88,7 +89,7 @@ public void onIntegrationUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Integration Update Event"); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().warningColor()); String implementationNotice = "We do not have sufficient data to log the changes in an INTEGRATION_UPDATE Event." .concat(" A proper implementation might happen in future releases if such an event is fired consistently."); @@ -114,7 +115,7 @@ public void onIntegrationDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Integration Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Integration Deleted By: " + mentionableExecutor)); - eb.setColor(Color.MAGENTA); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -150,7 +151,7 @@ public void onApplicationCommandPrivilegesUpdate(@NonNull GuildAuditLogEntryCrea EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Application Command Privilege Update"); eb.setDescription(MarkdownUtil.quoteBlock("Application Command Privilege Updated By: " + mentionableExecutor)); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("More Info"), MarkdownUtil.codeblock("To know more about what changes were made, visit the Integrations section"), false); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java index 1f17dcf..9c44397 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/InviteActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class InviteActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public InviteActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public InviteActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -56,7 +57,7 @@ public void onInviteCreate(@NonNull GuildAuditLogEntryCreateEvent event) { eb.setTitle("Audit Log Entry | Invite Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Invite Created By: " + mentionableExecutor)); - eb.setColor(Color.CYAN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -113,7 +114,7 @@ public void onInviteUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Invite Update Event"); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().warningColor()); String implementationNotice = "We do not have sufficient data to log the changes in an INVITE_UPDATE Event" .concat(" because invites seem to be immutable at the moment, which causes this event to not be fired.") @@ -141,7 +142,7 @@ public void onInviteDelete(@NonNull GuildAuditLogEntryCreateEvent event) { String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getUserId()); eb.setDescription(MarkdownUtil.quoteBlock("Invite Deleted By: " + mentionableExecutor)); - eb.setColor(Color.BLUE); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java index 7d94638..88db81f 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MemberUpdateActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class MemberUpdateActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MemberUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MemberUpdateActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -58,7 +59,7 @@ public void onMemberUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Member Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Executor: " + mentionableExecutor + "\nTarget: " + mentionableTargetUser)); - eb.setColor(Color.CYAN); + eb.setColor(environment.embedColor().warningColor()); if (targetUser != null) eb.setThumbnail(targetUser.getEffectiveAvatarUrl()); @@ -71,10 +72,10 @@ public void onMemberUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { case "communication_disabled_until" -> { if (newValue == null) { - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Timeout Lifted"), "╰┈➤ Timeout has been removed", false); } else { - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Timeout Received"), "╰┈➤ Member has received a timeout", false); eb.addField(MarkdownUtil.underline("Timeout Ends On"), "╰┈➤" + DurationUtils.isoToLocalTimeCounter(newValue), false); eb.addField(MarkdownUtil.underline("Timeout Reason"), "╰┈➤" + (ale.getReason() != null ? ale.getReason() : "No Reason Provided"), false); @@ -121,7 +122,7 @@ public void onMemberRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Member Role Update"); eb.setDescription(MarkdownUtil.quoteBlock("Executor: " + mentionableExecutor + "\nTarget: " + mentionableTargetUser)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); if (targetUser != null) eb.setThumbnail(targetUser.getEffectiveAvatarUrl()); @@ -166,7 +167,7 @@ public void onMemberVoiceKick(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Member Voice Kick Event"); eb.setDescription(MarkdownUtil.quoteBlock("Member Kicked From a Voice Channel\n By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().warningColor()); eb.setFooter("Audit Log Entry ID: " + ale.getId()); eb.setTimestamp(ale.getTimeCreated()); @@ -189,7 +190,7 @@ public void onMemberVoiceMove(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Member Voice Move Event"); eb.setDescription(MarkdownUtil.quoteBlock("Member Moved To A Different Voice Channel\n By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.setFooter("Audit Log Entry ID: " + ale.getId()); eb.setTimestamp(ale.getTimeCreated()); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java index 75f3460..6e6f3c8 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessageActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,19 +15,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class MessageActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MessageActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MessageActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -64,7 +65,7 @@ public void onMessageDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Message Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Executor: " + mentionableExecutor)); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().destructiveColor()); eb.setFooter("Audit Log Entry ID: " + ale.getId()); eb.setTimestamp(ale.getTimeCreated()); @@ -85,7 +86,7 @@ public void onMessageBulkDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Bulk Message Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Executor: " + mentionableExecutor)); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().destructiveColor()); eb.setFooter("Audit Log Entry ID: " + ale.getId()); eb.setTimestamp(ale.getTimeCreated()); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java index bcfd5f1..c6737c3 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/MessagePinActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.MessageUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class MessagePinActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public MessagePinActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public MessagePinActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -57,7 +58,7 @@ public void onMessagePin(@NonNull GuildAuditLogEntryCreateEvent event) { String mentionableTarget = (target != null ? target.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Message Pinned By: " + mentionableExecutor + "\nMessage Author: " + mentionableTarget)); - eb.setColor(Color.PINK); + eb.setColor(environment.embedColor().successColor()); eb.addField( MarkdownUtil.underline("Pinned Message Jump URL"), @@ -88,7 +89,7 @@ public void onMessageUnpin(@NonNull GuildAuditLogEntryCreateEvent event) { String mentionableTarget = (target != null ? target.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Message Un-Pinned By: " + mentionableExecutor + "\nMessage Author: " + mentionableTarget)); - eb.setColor(Color.MAGENTA); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Un-Pinned Message Jump URL"), diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java index dabd030..f856f58 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ModActionActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,19 +15,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class ModActionActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ModActionActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ModActionActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -58,7 +59,7 @@ public void onKick(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Kick Event"); eb.setDescription(MarkdownUtil.quoteBlock("A Member Has Been Kicked By: " + mentionableModerator)); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Kicked Member"), "╰┈➤" + mentionableKickedUser, false); eb.addField(MarkdownUtil.underline("Reason"), "╰┈➤" + reasonForKick, false); @@ -90,7 +91,7 @@ public void onBan(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Ban Event"); eb.setDescription(MarkdownUtil.quoteBlock("A Member Has Been Banned By: " + mentionableModerator)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); eb.addField(MarkdownUtil.underline("Banned Member"), "╰┈➤" + mentionableBannedUser, false); eb.addField(MarkdownUtil.underline("Ban Reason"), "╰┈➤" + reasonForBan, false); @@ -119,7 +120,7 @@ public void onUnban(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Member Unban Event"); eb.setDescription(MarkdownUtil.quoteBlock("A Member Has Been Un-Banned By: " + mentionableModerator)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Un-banned User"), "╰┈➤" + mentionableUnbannedUser, false); @@ -146,7 +147,7 @@ public void onBotAdd(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Bot Add Event"); eb.setDescription(MarkdownUtil.quoteBlock("Bot Added By: " + mentionableExecutor + "\nBot ID: " + ale.getTargetId())); - eb.setColor(Color.CYAN); + eb.setColor(environment.embedColor().successColor()); eb.addField(MarkdownUtil.underline("Bot Added"), "╰┈➤" + mentionableTarget, false); @@ -168,7 +169,7 @@ public void onPrune(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Prune Event"); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().warningColor()); String implementationNotice = "We do not have sufficient payload data to log the changes in a PRUNE Event." .concat(" A proper implementation might happen in future releases"); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java index ae4d1f9..42233c5 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.OnboardingUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class OnboardingActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public OnboardingActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public OnboardingActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -53,7 +54,7 @@ public void onOnboardingCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Onboarding Create Event"); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().successColor()); String implementationNotice = "We do not have sufficient data to log the changes in an ONBOARDING_CREATE Event." .concat(" That is because, even for Onboarding creations, ONBOARDING_UPDATE is fired instead.") @@ -83,7 +84,7 @@ public void onOnboardingUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { Guild guild = event.getGuild(); eb.setDescription(MarkdownUtil.quoteBlock("Onboarding Settings Updated By: " + mentionableExecutor)); - eb.setColor(Color.MAGENTA); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java index b15a3f1..384de9e 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/OnboardingPromptActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class OnboardingPromptActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public OnboardingPromptActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public OnboardingPromptActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -54,7 +55,7 @@ public void onOnboardingPromptCreate(@NonNull GuildAuditLogEntryCreateEvent even String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Onboarding Prompt Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -108,7 +109,7 @@ public void onOnboardingPromptUpdate(@NonNull GuildAuditLogEntryCreateEvent even String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Onboarding Prompt Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -170,7 +171,7 @@ public void onOnboardingPromptDelete(@NonNull GuildAuditLogEntryCreateEvent even String mentionableExecutor = (executor != null ? executor.getAsMention() : ale.getTargetId()); eb.setDescription(MarkdownUtil.quoteBlock("Onboarding Prompt Deleted By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java index 9fed180..a32856c 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.RoleUtils; @@ -17,19 +18,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class RoleActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public RoleActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public RoleActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -58,7 +59,7 @@ public void onRoleCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Role Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Role Created By: " + mentionableExecutor + "\nTarget Role: " + mentionableTargetRole)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -109,7 +110,7 @@ public void onRoleUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Role Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Role Updated By: " + mentionableExecutor + "\nTarget Role: " + mentionableTargetRole)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -184,7 +185,7 @@ public void onRoleDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Role Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Role Deleted By: " + mentionableExecutor + "\nTarget Role ID: " + ale.getTargetId())); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java index 7c2b2da..e98b969 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ScheduledEventActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.ScheduledEventUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class ScheduledEventActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ScheduledEventActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ScheduledEventActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -53,7 +54,7 @@ public void onScheduledEventCreate(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Scheduled Event Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Scheduled Event Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -101,7 +102,7 @@ public void onScheduledEventUpdate(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Scheduled Event Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Scheduled Event Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -181,7 +182,7 @@ public void onScheduledEventDelete(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Scheduled Event Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Scheduled Event Deleted By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java index dbbc791..e51a2bd 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/SoundboardActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.SoundboardUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class SoundboardActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public SoundboardActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public SoundboardActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -53,7 +54,7 @@ public void onSoundboardSoundCreate(@NonNull GuildAuditLogEntryCreateEvent event EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Soundboard Sound Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sound Item Added By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -100,7 +101,7 @@ public void onSoundboardSoundUpdate(@NonNull GuildAuditLogEntryCreateEvent event EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Soundboard Sound Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sound Item Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -156,7 +157,7 @@ public void onSoundboardSoundDelete(@NonNull GuildAuditLogEntryCreateEvent event EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Soundboard Sound Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sound Item Deleted By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java index 41a5bf8..f339c87 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StageInstanceActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.StageUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class StageInstanceActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public StageInstanceActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public StageInstanceActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -53,7 +54,7 @@ public void onStageInstanceCreate(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Stage Instance Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Stage Instance Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -91,7 +92,7 @@ public void onStageInstanceUpdate(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Stage Instance Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Stage Instance Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -135,7 +136,7 @@ public void onStageInstanceDelete(@NonNull GuildAuditLogEntryCreateEvent event) EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Stage Instance Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Stage Instance Deleted By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java index 34a3305..415c57c 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/StickerActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.StickerUtils; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; @@ -16,19 +17,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class StickerActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public StickerActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public StickerActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -57,7 +58,7 @@ public void onStickerCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Sticker Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sticker Created By: " + mentionableExecutor + "\nCreated Sticker: " + mentionableSticker)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -105,7 +106,7 @@ public void onStickerUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Sticker Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sticker Updated By: " + mentionableExecutor + "\nUpdated Sticker: " + mentionableSticker)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -159,7 +160,7 @@ public void onStickerDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Sticker Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Sticker Deleted By: " + mentionableExecutor + "\nDeleted Sticker ID: " + mentionableSticker)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java index b1abc8a..516373d 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/ThreadActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.BooleanUtils; import io.github.eggy03.papertrail.bot.utils.DurationUtils; @@ -19,19 +20,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class ThreadActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public ThreadActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public ThreadActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -60,7 +61,7 @@ public void onThreadCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Thread Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Thread Created By: " + mentionableExecutor + "\nTarget Thread: " + mentionableTargetThread)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -120,7 +121,7 @@ public void onThreadUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Thread Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Thread Updated By: " + mentionableExecutor + "\nTarget Thread: " + mentionableTargetThread)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { @@ -195,7 +196,7 @@ public void onThreadDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Thread Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Thread Deleted By: " + mentionableExecutor + "\nTarget Thread ID: " + ale.getTargetId())); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java index 70ad89a..32e9028 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/UnknownActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -14,8 +15,6 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - // for events not defined by JDA @ApplicationScoped @Slf4j @@ -23,11 +22,13 @@ public final class UnknownActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public UnknownActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public UnknownActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -54,7 +55,7 @@ public void onUnknownActionType(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Generic Event"); eb.setDescription(MarkdownUtil.quoteBlock("Executor: " + mentionableExecutor)); - eb.setColor(Color.LIGHT_GRAY); + eb.setColor(environment.embedColor().warningColor()); eb.addField(MarkdownUtil.underline("Action Type"), MarkdownUtil.codeblock(ale.getType().toString()), true); eb.addField(MarkdownUtil.underline("Target Type"), MarkdownUtil.codeblock(ale.getTargetType().toString()), true); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java index 2461727..97804fb 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/VoiceChannelStatusActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.entity.PaperTrailGuild; @@ -15,19 +16,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class VoiceChannelStatusActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public VoiceChannelStatusActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public VoiceChannelStatusActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -57,7 +58,7 @@ public void onVoiceChannelStatusUpdate(@NonNull GuildAuditLogEntryCreateEvent ev eb.setTitle("Audit Log Entry | Voice Channel Status Update"); eb.setDescription("A voice channel status has been updated"); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); eb.addField( MarkdownUtil.underline("Details"), @@ -92,9 +93,9 @@ public void onVoiceChannelStatusDelete(@NonNull GuildAuditLogEntryCreateEvent ev eb.setTitle("Audit Log Entry | Voice Channel Status Delete"); eb.setDescription("A voice channel status has been reset"); - eb.setColor(Color.ORANGE); + eb.setColor(environment.embedColor().destructiveColor()); - // status deletes dont contain the deleted status content + // status deletes don't contain the deleted status content eb.addField( MarkdownUtil.underline("Details"), MarkdownUtil.quoteBlock("Status Reset By: " + mentionableExecutor + "\n" + "Target Channel: " + mentionableTargetChannel), diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java index dda9dce..12fadcc 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/WebhookActionTypeHandler.java @@ -1,5 +1,6 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.auditlog; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.bot.utils.auditlog.GuildUtils; import io.github.eggy03.papertrail.bot.utils.auditlog.WebhookUtils; @@ -16,19 +17,19 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; - @ApplicationScoped @Slf4j @SuppressWarnings("java:S1192") public final class WebhookActionTypeHandler extends AbstractGuildAuditLogEntryCreateEventActionTypeHandler { private final @NonNull PaperTrailGuildClient client; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public WebhookActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull EmbedCheckingService embedCheckingService) { + public WebhookActionTypeHandler(@NonNull PaperTrailGuildClient client, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.client = client; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -54,7 +55,7 @@ public void onWebhookCreate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Webhook Create Event"); eb.setDescription(MarkdownUtil.quoteBlock("Webhook Created By: " + mentionableExecutor)); - eb.setColor(Color.GREEN); + eb.setColor(environment.embedColor().successColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -97,7 +98,7 @@ public void onWebhookUpdate(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Webhook Update Event"); eb.setDescription(MarkdownUtil.quoteBlock("Webhook Updated By: " + mentionableExecutor)); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); @@ -154,7 +155,7 @@ public void onWebhookDelete(@NonNull GuildAuditLogEntryCreateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Audit Log Entry | Webhook Remove Event"); eb.setDescription(MarkdownUtil.quoteBlock("Webhook Removed By: " + mentionableExecutor)); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); ale.getChanges().forEach((changeKey, changeValue) -> { Object oldValue = changeValue.getOldValue(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java index 18d7a66..c66ea84 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/message/GuildMessageEventHandler.java @@ -1,6 +1,7 @@ package io.github.eggy03.papertrail.bot.service.handlers.guild.message; import com.google.common.base.Splitter; +import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; import io.github.eggy03.papertrail.bot.service.EmbedCheckingService; import io.github.eggy03.papertrail.http.client.PaperTrailGuildClient; import io.github.eggy03.papertrail.http.client.PaperTrailMessageClient; @@ -18,7 +19,6 @@ import net.dv8tion.jda.api.utils.MarkdownUtil; import org.jspecify.annotations.Nullable; -import java.awt.Color; import java.time.Instant; import java.util.List; import java.util.Optional; @@ -29,12 +29,14 @@ public final class GuildMessageEventHandler { private final @NonNull PaperTrailGuildClient paperTrailGuildClient; private final @NonNull PaperTrailMessageClient paperTrailMessageClient; + private final @NonNull PaperTrailEnvironment environment; private final @NonNull EmbedCheckingService embedCheckingService; @Inject - public GuildMessageEventHandler(@NonNull PaperTrailGuildClient paperTrailGuildClient, @NonNull PaperTrailMessageClient paperTrailMessageClient, @NonNull EmbedCheckingService embedCheckingService) { + public GuildMessageEventHandler(@NonNull PaperTrailGuildClient paperTrailGuildClient, @NonNull PaperTrailMessageClient paperTrailMessageClient, @NonNull PaperTrailEnvironment environment, @NonNull EmbedCheckingService embedCheckingService) { this.paperTrailGuildClient = paperTrailGuildClient; this.paperTrailMessageClient = paperTrailMessageClient; + this.environment = environment; this.embedCheckingService = embedCheckingService; } @@ -89,7 +91,7 @@ public void handleMessageUpdateEvent(@NonNull MessageUpdateEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Message Edit Event"); eb.setDescription(MarkdownUtil.quoteBlock("Author: " + updatedMessageAuthor + "\n" + "Channel: " + event.getChannel().getAsMention())); - eb.setColor(Color.YELLOW); + eb.setColor(environment.embedColor().warningColor()); oldMessageSplits.forEach(split -> eb.addField(MarkdownUtil.underline("Old Message"), MarkdownUtil.codeblock(split), false)); updatedMessageSplits.forEach(split -> eb.addField(MarkdownUtil.underline("New Message"), MarkdownUtil.codeblock(split), false)); @@ -125,7 +127,7 @@ public void handleMessageDeleteEvent(@NonNull MessageDeleteEvent event) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Message Delete Event"); eb.setDescription(MarkdownUtil.quoteBlock("Author: " + mentionableAuthor + "\n" + "Channel: " + event.getChannel().getAsMention())); - eb.setColor(Color.RED); + eb.setColor(environment.embedColor().destructiveColor()); deletedMessageSplits.forEach(split -> eb.addField(MarkdownUtil.underline("Deleted Message"), MarkdownUtil.codeblock(split), false)); From e810b27b3bca8960a5b4692932bb6f8bd1764b8e Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:55:26 +0530 Subject: [PATCH 09/17] feat: allow configurable app name and activity Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../environment/PaperTrailEnvironment.java | 4 +++ .../misc/ActivityUpdateListener.java | 29 +++++-------------- src/main/resources/application.properties | 5 ++-- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java b/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java index 3b40808..51a51a0 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/environment/PaperTrailEnvironment.java @@ -24,6 +24,10 @@ interface General { @NonNull String appVersion(); + @WithName("app.activity") + @NonNull + String appActivity(); + @WithName("github.issue.link") @NonNull String githubIssueLink(); diff --git a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java index 62ae1c6..de49ba2 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/listeners/misc/ActivityUpdateListener.java @@ -1,8 +1,6 @@ package io.github.eggy03.papertrail.bot.listeners.misc; import io.github.eggy03.papertrail.bot.environment.PaperTrailEnvironment; -import io.quarkus.runtime.ImageMode; -import io.quarkus.runtime.LaunchMode; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import lombok.NonNull; @@ -29,9 +27,13 @@ public ActivityUpdateListener(@NonNull ShardManager manager, @NonNull PaperTrail @Override public void onReady(@NonNull ReadyEvent event) { // update on cold start - manager.setActivity(Activity.customStatus( - "/setup | " + paperTrailEnvironment.general().appVersion() + " | " + getImageMode() + " | " + getLaunchMode()) - ); + + String customActivity = paperTrailEnvironment.general().appActivity(); + if (customActivity.isBlank()) { + manager.setActivity(Activity.customStatus("/help | v" + paperTrailEnvironment.general().appVersion())); + } else + manager.setActivity(Activity.customStatus(customActivity)); + } @Override @@ -43,21 +45,4 @@ public void onGuildJoin(@NonNull GuildJoinEvent event) { // update on guild join public void onGuildLeave(@NonNull GuildLeaveEvent event) { // update on guild leave log.info("Bot Removed From [Guild={}, ID={}]", event.getGuild().getName(), event.getGuild().getId()); } - - private @NonNull String getLaunchMode() { - return switch (LaunchMode.current()) { - case DEVELOPMENT -> "Dev"; - case NORMAL -> "Production"; - case RUN -> "Production w/ Dev Services"; - case TEST -> "Test"; - }; - } - - private @NonNull String getImageMode() { - return switch (ImageMode.current()) { - case JVM -> "JVM"; - case NATIVE_BUILD -> "Native Build Phase"; - case NATIVE_RUN -> "Native"; - }; - } } \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 7984347..f3f4962 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,7 @@ # General -papertrail.general.app.name=PaperTrail +papertrail.general.app.name=${APP_NAME:PaperTrailBot} papertrail.general.app.version=${quarkus.application.version:N/A} +papertrail.general.app.activity=${APP_ACTIVITY: } papertrail.general.github.issue.link=https://github.com/eggy03/PaperTrailBot/issues # Token @@ -20,7 +21,7 @@ quarkus.management.port=${MANAGEMENT_PORT:9000} # Logging Level quarkus.log.level=${GLOBAL_LOG_LEVEL:INFO} -quarkus.log.category."io.github.eggy03.papertrail".level=${APPLICATION_LOG_LEVEL:INFO} +quarkus.log.category."io.github.eggy03.papertrail".level=${APP_LOG_LEVEL:INFO} # Analytics quarkus.analytics.disabled=true From 51ca5c800fefb453908690aa9714076e4e192a9a Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:59:45 +0530 Subject: [PATCH 10/17] refactor: ignore `unicode_emoji` for role creations and deletions Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../handlers/guild/auditlog/RoleActionTypeHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java index a32856c..736aecc 100644 --- a/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java +++ b/src/main/java/io/github/eggy03/papertrail/bot/service/handlers/guild/auditlog/RoleActionTypeHandler.java @@ -77,7 +77,7 @@ public void onRoleCreate(@NonNull GuildAuditLogEntryCreateEvent event) { * and delegates them to ROLE_UPDATE event */ } - case "icon_hash" -> { + case "icon_hash", "unicode_emoji" -> { // ignore } @@ -210,7 +210,7 @@ public void onRoleDelete(@NonNull GuildAuditLogEntryCreateEvent event) { case "colors" -> eb.addField(MarkdownUtil.underline("Gradient Color System"), RoleUtils.formatGradientToHex(oldValue), false); - case "icon_hash" -> { + case "icon_hash", "unicode_emoji" -> { // ignore } From d7b67b6d2b330485fd9c3feeeba4fe895b7eec3d Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 11:14:52 +0530 Subject: [PATCH 11/17] build: update dependencies Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9d419f2..52d34ed 100644 --- a/pom.xml +++ b/pom.xml @@ -18,12 +18,12 @@ quarkus-bom io.quarkus.platform - 3.39.2 + 3.39.5 true - 6.6.0 - 1.0.0 + 6.7.0 + 4.0.0 3.20.0 33.7.1-jre 26.1.0 From 1fc93f56ff881882d6006d70fbf788599c03215f Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 11:15:18 +0530 Subject: [PATCH 12/17] build: bump project version to 5.0.0 Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52d34ed..47e11bd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.eggy03 papertrailbot - 4.2.4 + 5.0.0 PaperTrail Bot A simple bot for logging all server and member actions quarkus From 221b9e0ac5ba7cf034236346affff0d9a30b828e Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 11:44:20 +0530 Subject: [PATCH 13/17] refactor: update reachability-metadata for http client Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .../papertrailbot/reachability-metadata.json | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/main/resources/META-INF/native-image/io/github/eggy03/papertrailbot/reachability-metadata.json b/src/main/resources/META-INF/native-image/io/github/eggy03/papertrailbot/reachability-metadata.json index e12f938..3c0c79f 100644 --- a/src/main/resources/META-INF/native-image/io/github/eggy03/papertrailbot/reachability-metadata.json +++ b/src/main/resources/META-INF/native-image/io/github/eggy03/papertrailbot/reachability-metadata.json @@ -1,34 +1,19 @@ { "reflection": [ { - "type": "io.github.eggy03.papertrail.sdk.client.AuditLogRegistrationClient" + "type": "io.github.eggy03.papertrail.http.client.PaperTrailGuildClient" }, { - "type": "io.github.eggy03.papertrail.sdk.client.MessageLogContentClient" + "type": "io.github.eggy03.papertrail.http.client.PaperTrailMessageClient" }, { - "type": "io.github.eggy03.papertrail.sdk.client.MessageLogRegistrationClient" - }, - { - "type": "io.github.eggy03.papertrail.sdk.entity.AuditLogRegistrationEntity", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "type": "io.github.eggy03.papertrail.sdk.entity.MessageLogContentEntity", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "type": "io.github.eggy03.papertrail.sdk.entity.MessageLogRegistrationEntity", + "type": "io.github.eggy03.papertrail.http.entity.PaperTrailGuild", "allDeclaredConstructors": true, "allDeclaredFields": true, "allDeclaredMethods": true }, { - "type": "io.github.eggy03.papertrail.sdk.entity.ErrorEntity", + "type": "io.github.eggy03.papertrail.http.entity.PaperTrailMessage", "allDeclaredConstructors": true, "allDeclaredFields": true, "allDeclaredMethods": true @@ -36,21 +21,14 @@ { "type": { "proxy": [ - "io.github.eggy03.papertrail.sdk.service.AuditLogRegistrationService" - ] - } - }, - { - "type": { - "proxy": [ - "io.github.eggy03.papertrail.sdk.service.MessageLogRegistrationService" + "io.github.eggy03.papertrail.http.service.PaperTrailGuildService" ] } }, { "type": { "proxy": [ - "io.github.eggy03.papertrail.sdk.service.MessageLogContentService" + "io.github.eggy03.papertrail.http.service.PaperTrailMessageService" ] } }, From fe85f0dd355d8aeb7ef8416c11e6d1da94e80a8c Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 13:54:04 +0530 Subject: [PATCH 14/17] refactor: update deployment guide Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- .env.example | 9 -- DEPLOYMENT.md | 406 +++++++++++--------------------------------------- 2 files changed, 83 insertions(+), 332 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index ba89461..0000000 --- a/.env.example +++ /dev/null @@ -1,9 +0,0 @@ -#Mandatory -TOKEN= -API_URL= - -#Optional -PORT= -MANAGEMENT_PORT= -GLOBAL_LOG_LEVEL= -APPLICATION_LOG_LEVEL= \ No newline at end of file diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index cd6cf73..e42eccb 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -1,40 +1,4 @@ -_Last Updated : August 07, 2026_ - -# Table of Contents - -* [Overview](#overview) -* [LITE vs ORIGINAL](#difference-between-original-and-lite-editions) -* [Deployment](#deployment) -* [Sharding](#sharding) -* [Synchronizing Rate Limits](#synchronizing-rate-limits) -* [Health Checks](#health-checks-and-custom-port-configuration) -* [Native-Builds](#native-builds) - -# Overview - -This section will show you how to deploy the `ORIGINAL` version of the bot. - -To deploy the `LITE` edition check out [this](https://github.com/eggy03/PaperTrailBot-Lite) repository. - -# Difference between `ORIGINAL` and `LITE` editions - -The `ORIGINAL` edition is designed to support self-hosting, horizontal scaling, customizable sharding. This requires you -to deploy/lease one or many instances of the PaperTrail API, a Redis/Valkey service and a database service. Very soon I -realized that this creates a bit of maintenance overhead for users. - -This is where `LITE` edition was proposed. It is a fork of the `ORIGINAL` edition but is designed with greater -personalization and easier setup in mind. It does not require a separate API or database service, just a Redis/Valkey -instance, and allows for greater customization during setup, most of which comes with sane defaults as well. This makes -it easy to set it up and get it working. However, the `LITE` edition can log only for a single server and does not -support scaling or sharding. - -Other than the aforementioned differences, everything else is identical between the two editions. - -If you are self-hosting it, you will probably host it for your own server, and hence in most cases, `LITE` edition is -the recommended one. - -You should use the `ORIGINAL` edition only if you need capabilities that are not available in the `LITE` edition, -such as manual sharding or horizontal scaling. +_Last Updated : October 03, 2026_ # Deployment @@ -81,289 +45,85 @@ Note down the `BOT TOKEN` since it will be shown only once and will be required ## Step 3: Deploying the Bot -### 3.1: Get Required Secrets - -| Variable | Description | Default Value | Optional | -|-----------|-----------------------------------------------------------|------------------|----------| -| `TOKEN` | Discord application bot token (from the Developer Portal) | No Default Value | No | -| `API_URL` | Internal URL of the PaperTrail API | No Default Value | No | - -Example `.env` file: - -```dotenv -TOKEN="my-token" -API_URL="http://localhost:8080" -``` - -### 3.2: Deployment Options - -#### Option A : Deploy Using Pre-Built Docker Images - -The GitHub Container Registry for this repository -has pre-built docker images for both JVM and Native versions the bot which you can use. - -[Container Registry for JVM Edition](https://github.com/eggy03/PaperTrailBot/pkgs/container/papertrail-bot) - -[Container Registry for Native Edition](https://github.com/eggy03/PaperTrailBot/pkgs/container/papertrail-bot-native) - -You may choose either one. - -To know more about native builds, visit the [bottom](#native-builds) of this guide. - -```bash -# JVM -docker run -d --name papertrail-bot --env-file .env ghcr.io/eggy03/papertrail-bot:latest -``` - -```bash -# Native -docker run -d --name papertrail-bot-native --env-file .env ghcr.io/eggy03/papertrail-bot-native:latest -``` - -#### Option B : Building From Source With Docker - -```bash -git clone https://github.com/eggy03/PaperTrailBot.git -cd PaperTrailBot -``` - -```bash -# JVM -docker build -t papertrail-bot . -docker run -d --name papertrail-bot --env-file .env papertrail-bot -``` - -```bash -# Native -docker build -f Dockerfile.native -t papertrail-bot-native . -docker run -d --name papertrail-bot-native --env-file .env papertrail-bot-native -``` - -#### Option C : Building From Source Without Docker - -```bash -git clone https://github.com/eggy03/PaperTrailBot.git -cd PaperTrailBot -``` - -```bash -# JVM -./mvnw clean package -java -jar target/quarkus-app/quarkus-run.jar -``` - -```bash -# Native -./mvnw clean package -Dnative -``` - -The built application will be found in the `target` folder of the project. - -#### Option D : Cloud Deployment - -If your cloud supports building from Dockerfile, point the source towards `Dockerfile` (for JVM Build) -or `Dockerfile.native` (for Native Build), found in the project's root. - -If your cloud supports using pre-built docker images, you can find the image links in -the container registry. - -## Step 4: Testing your deployment - -Upon successful deployment of all the required services, including the bot, you can run the slash command -`/setup` in a server where the bot has been invited. The command will tell you how to configure your bot. - -# Sharding - -> [!NOTE] -> Sharding is required only when your bot reaches 2500 servers. - -Sharding splits your bot connection into multiple independent connections to the Discord gateway. -Each independent connection is called a shard. -Discord allows you to have up to 2500 guilds per shard but the recommended configuration is 1 shard per 1000 guilds. - -You will need the following additional environment variables for custom shard configuration. - -| Variable | Description | Default Value | Optional | -|----------------|-------------------------------------------------------------------------------|---------------|----------| -| `TOTAL_SHARDS` | Total number of shards used by the bot across all running processes/instances | 1 | Yes | -| `MIN_SHARD_ID` | The first shard ID handled by this specific bot instance | 0 | Yes | -| `MAX_SHARD_ID` | The last shard ID handled by this specific bot instance | 0 | Yes | - -Shard IDs start at 0. - -If `TOTAL_SHARDS=5`, the valid shard IDs are: - -``` -0 1 2 3 4 -``` - -Take a look at the following configuration examples to have a clearer picture of what values to put -for your use-case - -#### Example 1: Single Process / Small Bot (<2500 Guilds) - -If your bot is small or self-hosted for a limited number of servers (<2500), one shard is sufficient. -This is the default pre-applied configuration when you do not provide any manual shard info. - -```dotenv -TOTAL_SHARDS=1 -MIN_SHARD_ID=0 -MAX_SHARD_ID=0 -``` - -#### Example 2: Single Process / Medium Bot (2500 - 5000 Guilds) - -If your bot exceeds the 2500 guild limit for a single shard, you can increase the shard count while still running one -process: - -```dotenv -TOTAL_SHARDS=2 -MIN_SHARD_ID=0 -MAX_SHARD_ID=1 -``` - -Remember that each shard can only handle up to 2500 guilds so plan the total number shards accordingly - -#### Example 3: 2 Bot Processes / 25000 Guilds - -If you run your bot across multiple processes, you need to split the shards between them. - -Process/Instance 1: - -```dotenv -TOTAL_SHARDS=10 -MIN_SHARD_ID=0 -MAX_SHARD_ID=4 -``` - -Process/Instance 2: - -```dotenv -TOTAL_SHARDS=10 -MIN_SHARD_ID=5 -MAX_SHARD_ID=9 -``` - -Process 1 handles shards 0-4 and Process 2 handles 5-9. -Each process manages 5 shards, together covering all 10 shards. - -> [!IMPORTANT] -> Shard ID ranges must never overlap between running bot processes/instances. -> -> `TOTAL_SHARDS` count must be equal for all instances and must reflect the total shards used across all instances -> combined. - -# Synchronizing Rate Limits - -> [!NOTE] -> This section is required only if you have multiple instances of the bot running, like in Example 3 of Sharding. - -When you run multiple instances/process, the JDA in each process thinks that it has the sole responsibility -of handling Discord's API rate limits because the processes aren't aware of each other's existence. -This means, without some sort of communication or synchronization between the instances, you may exceed the rate limits -pretty early. - -It is possible to synchronize Discord's rate limits across multiple instances/processes -by using an external proxy such as the [Twilight HTTP Proxy](https://github.com/twilight-rs/http-proxy). -This proxy acts as a shared HTTP gateway that coordinates Discord API rate limits across multiple bot instances. - -This however, requires disabling the default rate limiter in JDA because the proxy will handle them globally. - -It is also worth noting that this feature is largely untested in PaperTrail. -Read more about this in the [Limitations](#limitations) section. - -### Running the Proxy - -To use the pre-built Docker images from -the [container registry](https://github.com/twilight-rs/http-proxy/pkgs/container/http-proxy), -run one of the following commands: - -```shell -$ docker run -itd -e DISCORD_TOKEN="my token" -p 3000:80 ghcr.io/twilight-rs/http-proxy -# Or with metrics enabled -$ docker run -itd -e DISCORD_TOKEN="my token" -p 3000:80 ghcr.io/twilight-rs/http-proxy:metrics - -``` - -This will set the discord token to `"my token"` and map the bound port to port `3000` on the host machine. - -### Bot Configuration - -Add the following environment variable to your bot: - -| Variable | Description | Default Value | Optional | -|---------------------------|----------------------------------------------------------------------------------------------------------------------------|---------------|----------| -| `TWILIGHT_HTTP_PROXY_URL` | Base URL for the HTTP proxy that will receive Discord API requests instead of discord.com (Example: http://localhost:3000) | Blank | Yes | - -When configured, all Discord API requests made by the bot will be routed through the proxy. - -### Limitations - -Twilight HTTP Proxy has its own global rate limiting feature and recommends clients to disable their per-instance -rate limit checks. That's because requests from all bot instances are centrally managed and throttled by the proxy -rather than by each client individually. - -For PaperTrail, this would mean replacing JDA's default `SequentialRestRateLimiter`, -which is an implementation of the `RestRateLimiter`, with a custom no-op implementation. -Such an implementation would effectively bypass JDA’s local rate-limit checks and defer all rate limiting to the proxy. -At the moment, PaperTrail does not provide such an implementation. - -This means that if you use a proxy for your bot clusters, you are effectively getting throttled at the proxy-level, as -well -as the instance-level. While this should not create functional conflicts, -it may lead to under-utilization of the rate limits provided by Discord and can reduce the overall throughput of your -bot cluster. - -# Health Checks and Custom Port Configuration - -### Health Checks - -Since v4, it is possible to get health information by probing any of the following health endpoints: - -| Endpoint | Description | -|---------------------|-------------------------------------------------------------------------------------------------------| -| `/q/health` | Aggregated health status containing all registered checks. | -| `/q/health/live` | Liveness probe. Verifies that the bot process is healthy and that all shards are operating normally. | -| `/q/health/ready` | Readiness probe. Verifies that all shards are fully connected to Discord and ready to receive events. | -| `/q/health/started` | Startup probe. Indicates whether the application has completed its startup sequence. | - -#### Liveness Check - -The liveness check reports **UP** when all shards belonging to this instance are in one of the following states: - -* `CONNECTED` -* `ATTEMPTING_TO_RECONNECT` -* `RECONNECT_QUEUED` -* `WAITING_TO_RECONNECT` - -#### Readiness Check - -The readiness check reports **UP** only when every shard belonging to this instance is fully `CONNECTED` to Discord. - -### Custom Port Configuration - -By, default PaperTrail runs on port 8080. If port 8080 is occupied by a different service, or you wish to -run the application on a different port, you can manually set the `PORT` environment variable. Same goes for -`MANAGEMENT_PORT` which will expose the health check endpoints. - -| Variable | Description | Default Value | Optional | -|-------------------|-------------------------------------------------------|---------------|----------| -| `PORT` | Port Number on which the instance of the bot will run | 8080 | Yes | -| `MANAGEMENT_PORT` | Port for Health Check Interface | 9000 | Yes | - -# Native Builds - -> [!CAUTION] -> Native builds are experimental - -Since `v4.1.3` it is possible to create and use native builds of the bot. Native builds are recommended -when you are hosting the bot in a very resource constrained environment, -and you need the bot to have faster startup times and low memory consumption. - -Native builds have a larger and resource incentive build time compared to standard JVM builds. - -Please note that native builds are experimental and I will try my best to improve support for it in upcoming versions. - -You may come across errors which require you to initialize classes during build time -or missing reflection config during runtime. -If you run across such errors, create an Issue in GitHub along with the build or runtime logs. +### 3.1: Get Required Variables + +| Variable | Description | Default Value | Optional | +|------------------|-----------------------------------------------------------|------------------|----------| +| `DB_HOST` | PostgreSQL database host/address | No Default Value | No | +| `DB_PORT` | PostgreSQL database port | No Default Value | No | +| `DB_NAME` | PostgreSQL database name | No Default Value | No | +| `DB_USERNAME` | PostgreSQL database username | No Default Value | No | +| `DB_PASSWORD` | PostgreSQL database password | No Default Value | No | +| `REDIS_USERNAME` | Redis/Valkey username | No Default Value | No | +| `REDIS_PASSWORD` | Redis/Valkey password | No Default Value | No | +| `REDIS_HOST` | Redis/Valkey server host/address | No Default Value | No | +| `REDIS_PORT` | Redis/Valkey server port | No Default Value | No | +| `TOKEN` | Discord application bot token (from the Developer Portal) | No Default Value | No | + +### 3.2: Deployment + +Use the following docker compose setup to deploy both the bot and the API + +```yaml +networks: + papertrail-network: + +services: + api: + container_name: papertrail-api + image: ghcr.io/eggy03/papertrail-api-native:latest + environment: + DB_URL: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} + DB_USERNAME: ${DB_USERNAME} + DB_PASSWORD: ${DB_PASSWORD} + REDIS_URL: rediss://${REDIS_USERNAME}:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT} + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:9000/q/health" ] + interval: 10s + timeout: 5s + retries: 3 + + bot: + container_name: papertrail-bot + image: ghcr.io/eggy03/papertrail-bot-native:latest + depends_on: + api: + condition: service_healthy + environment: + TOKEN: ${TOKEN} + API_URL: http://papertrail-api:8080 + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:9000/q/health" ] + interval: 10s + timeout: 5s + retries: 3 +``` + +If you want to build from source and then deploy individually, +you can point your builder to this [and the API] repository's +[Dockerfile](/Dockerfile) or [Dockerfile Native (GraalVM Native Image)](/Dockerfile.native). + +# Customization Options + +The following environment variables have defaults, but you can change them to allow for more customization: + +## Bot + +| Environment Variable | Description | Default Value | +|-------------------------------|------------------------------------------------------------|---------------------------| +| `APP_NAME` | Changes the application name used internally. | `PaperTrailBot` | +| `APP_ACTIVITY` | Changes the activity displayed by the bot in Discord. | `/help \| latest version` | +| `APP_LOG_LEVEL` | Changes the application log level. | `INFO` | +| `PORT` | Changes the port used by the application. | `8080` | +| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | +| `EMBED_SUCCESS_COLOR_INT` | Changes the color of embeds for **creation events**. | `GREEN (712458)` | +| `EMBED_WARNING_COLOR_INT` | Changes the color of embeds for **update events**. | `YELLOW (16776960)` | +| `EMBED_DESTRUCTIVE_COLOR_INT` | Changes the color of embeds for **deletion events**. | `RED (16711680)` | + +## API + +| Environment Variable | Description | Default Value | +|----------------------|------------------------------------------------------------|---------------| +| `LOG_LEVEL` | Changes the application log level. | `INFO` | +| `PORT` | Changes the port used by the application. | `8080` | +| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | \ No newline at end of file From 05bb30123ce4c0630e73e014f930854b2aa1b2e6 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 13:54:25 +0530 Subject: [PATCH 15/17] docs: replace dead links Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- README.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fd86676..4ce81ac 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,11 @@ Integrations, Webhooks, Moderation Action, Unusual DMs, Raids and Unknown events # Repositories -| Repository | Description | -|--------------------------------------------------------------------|-------------------------------------------------------------| -| [PaperTrailBot](https://github.com/eggy03/PaperTrailBot) | Core bot application | -| [PaperTrailBot Lite](https://github.com/eggy03/PaperTrailBot-Lite) | Same bot application but designed for self-hosting | -| [PaperTrail SDK](https://github.com/eggy03/papertrail-sdk) | Java client library for interacting with the API | -| [PaperTrail API](https://github.com/eggy03/PaperTrail-API-Quarkus) | API used by the core bot application to store server config | +| Repository | Description | +|----------------------------------------------------------------------------|--------------------------------------------------------------| +| [PaperTrailBot](https://github.com/eggy03/PaperTrailBot) | Core bot application | +| [PaperTrail HTTP Client](https://github.com/eggy03/PaperTrail-HTTP-Client) | Synchronous Java client library for interacting with the API | +| [PaperTrail API](https://github.com/eggy03/PaperTrail-API-Quarkus) | API used by the bot to store server config | > [!IMPORTANT] > I've considered putting the project in maintenance mode since I believe it's mostly feature complete. @@ -52,17 +51,11 @@ A deployed instance is the easiest way to use this bot. Just invite it to your s Get it from here: https://discord.com/discovery/applications/1381658412550590475 -Run the `/setup` slash command to see instructions on how to configure the bot for your server. +Run the `/help` slash command to see instructions on how to configure the bot for your server. ### By Self Hosting It -For self-hosting, I'd recommend the [LITE](https://github.com/eggy03/PaperTrailBot-Lite) version of the bot. The `LITE` -version requires lesser services to set up and offers more granular customization. However, you can only use it for a -single server. - -If you do not wish to use the `LITE` version, you can self-host the `ORIGINAL` version by reading the -guide [here](/DEPLOYMENT.md). -The guide also mentions the difference between the `LITE` and the `ORIGINAL` versions. +Read the deployment guide [here](/DEPLOYMENT.md) # License From 88ce6ca202b03ebaf5e94ae690560315fdde4a5d Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 14:02:54 +0530 Subject: [PATCH 16/17] chore: update base image to 9.8 Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- Dockerfile.native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.native b/Dockerfile.native index 351f6db..e24e79f 100644 --- a/Dockerfile.native +++ b/Dockerfile.native @@ -19,7 +19,7 @@ COPY src ./src RUN ./mvnw -B -e clean package -DskipTests -Dnative # ---------- Stage 2: Minimal Runtime ---------- -FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7 +FROM registry.access.redhat.com/ubi9/ubi-minimal:9.8 RUN microdnf install -y freetype fontconfig \ && microdnf clean all \ From b84f03fab4cde606fffde03941140c91ad550b80 Mon Sep 17 00:00:00 2001 From: Egg-03 <111327101+eggy03@users.noreply.github.com> Date: Sat, 3 Oct 2026 15:21:47 +0530 Subject: [PATCH 17/17] docs: simplify variables Signed-off-by: Egg-03 <111327101+eggy03@users.noreply.github.com> --- DEPLOYMENT.md | 65 ++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index e42eccb..e09bfd5 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -6,11 +6,7 @@ _Last Updated : October 03, 2026_ > > This guide assumes you already have a working PostgreSQL and Redis/Valkey instance or know how to set up one. -## Step 1: Setting up the API Service - -Follow this [guide](https://github.com/eggy03/PaperTrail-API-Quarkus?tab=readme-ov-file) - -## Step 2: Setting up the Bot In Discord +## Step 1: Create a bot in the Discord Dev Portal Log on to the [Discord Developer Portal](https://discord.com/developers/applications) and create an application. @@ -43,24 +39,19 @@ needed for it to work properly: Note down the `BOT TOKEN` since it will be shown only once and will be required in the later steps. -## Step 3: Deploying the Bot +## Step 2: Deploying the API and the Bot -### 3.1: Get Required Variables +### 2.1: Get Required Variables -| Variable | Description | Default Value | Optional | -|------------------|-----------------------------------------------------------|------------------|----------| -| `DB_HOST` | PostgreSQL database host/address | No Default Value | No | -| `DB_PORT` | PostgreSQL database port | No Default Value | No | -| `DB_NAME` | PostgreSQL database name | No Default Value | No | -| `DB_USERNAME` | PostgreSQL database username | No Default Value | No | -| `DB_PASSWORD` | PostgreSQL database password | No Default Value | No | -| `REDIS_USERNAME` | Redis/Valkey username | No Default Value | No | -| `REDIS_PASSWORD` | Redis/Valkey password | No Default Value | No | -| `REDIS_HOST` | Redis/Valkey server host/address | No Default Value | No | -| `REDIS_PORT` | Redis/Valkey server port | No Default Value | No | -| `TOKEN` | Discord application bot token (from the Developer Portal) | No Default Value | No | +| Variable | Description/Format | Default Value | Optional | +|---------------|----------------------------------------------------------------------|------------------|----------| +| `DB_URL` | jdbc:postgresql://:/ | No Default Value | No | +| `DB_USERNAME` | Database Username | No Default Value | No | +| `DB_PASSWORD` | Database Password | No Default Value | No | +| `REDIS_URL` | rediss://:@: | No Default Value | No | +| `TOKEN` | Get from the dev portal | No Default Value | No | -### 3.2: Deployment +### 2.2: Deployment Use the following docker compose setup to deploy both the bot and the API @@ -73,10 +64,10 @@ services: container_name: papertrail-api image: ghcr.io/eggy03/papertrail-api-native:latest environment: - DB_URL: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} + DB_URL: ${DB_URL} DB_USERNAME: ${DB_USERNAME} DB_PASSWORD: ${DB_PASSWORD} - REDIS_URL: rediss://${REDIS_USERNAME}:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT} + REDIS_URL: ${REDIS_URL} healthcheck: test: [ "CMD", "curl", "-f", "http://localhost:9000/q/health" ] interval: 10s @@ -109,21 +100,21 @@ The following environment variables have defaults, but you can change them to al ## Bot -| Environment Variable | Description | Default Value | -|-------------------------------|------------------------------------------------------------|---------------------------| -| `APP_NAME` | Changes the application name used internally. | `PaperTrailBot` | -| `APP_ACTIVITY` | Changes the activity displayed by the bot in Discord. | `/help \| latest version` | -| `APP_LOG_LEVEL` | Changes the application log level. | `INFO` | -| `PORT` | Changes the port used by the application. | `8080` | -| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | -| `EMBED_SUCCESS_COLOR_INT` | Changes the color of embeds for **creation events**. | `GREEN (712458)` | -| `EMBED_WARNING_COLOR_INT` | Changes the color of embeds for **update events**. | `YELLOW (16776960)` | -| `EMBED_DESTRUCTIVE_COLOR_INT` | Changes the color of embeds for **deletion events**. | `RED (16711680)` | +| Environment Variable | Description | Default Value | Optional | +|-------------------------------|------------------------------------------------------------|---------------------|-----------------| +| `APP_NAME` | Changes the application name used internally. | `PaperTrailBot` | Yes | +| `APP_ACTIVITY` | Changes the activity displayed by the bot in Discord. | `/help | latest version` | Yes | +| `APP_LOG_LEVEL` | Changes the application log level. | `INFO` | Yes | +| `PORT` | Changes the port used by the application. | `8080` | Yes | +| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | Yes | +| `EMBED_SUCCESS_COLOR_INT` | Changes the color of embeds for **creation events**. | `GREEN (712458)` | Yes | +| `EMBED_WARNING_COLOR_INT` | Changes the color of embeds for **update events**. | `YELLOW (16776960)` | Yes | +| `EMBED_DESTRUCTIVE_COLOR_INT` | Changes the color of embeds for **deletion events**. | `RED (16711680)` | Yes | ## API -| Environment Variable | Description | Default Value | -|----------------------|------------------------------------------------------------|---------------| -| `LOG_LEVEL` | Changes the application log level. | `INFO` | -| `PORT` | Changes the port used by the application. | `8080` | -| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | \ No newline at end of file +| Environment Variable | Description | Default Value | Optional | +|----------------------|------------------------------------------------------------|---------------|----------| +| `LOG_LEVEL` | Changes the application log level. | `INFO` | Yes | +| `PORT` | Changes the port used by the application. | `8080` | Yes | +| `MANAGEMENT_PORT` | Changes the management port used by Quarkus health checks. | `9000` | Yes | \ No newline at end of file