diff --git a/pom.xml b/pom.xml
index 58e13a2..712f4f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
io.github.eggy03
papertrailbot
- 4.2.1
+ 4.2.2
PaperTrail Bot
A simple bot for logging all server and member actions
quarkus
@@ -18,7 +18,7 @@
quarkus-bom
io.quarkus.platform
- 3.37.2
+ 3.37.3
true
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 c9ce6e9..6953b01 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
@@ -2,6 +2,7 @@
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;
@@ -19,7 +20,6 @@
import java.awt.Color;
import java.time.Instant;
import java.util.EnumSet;
-import java.util.Set;
@ApplicationScoped
public final class DebugCommandHandler {
@@ -28,18 +28,6 @@ public final class DebugCommandHandler {
private final @NonNull MessageLogRegistrationClient messageLogRegistrationClient;
private final @NonNull PaperTrailConfig paperTrailConfig;
- // necessary permissions for the bot to function
- @NonNull
- private final Set necessaryPermissions = EnumSet.of(
- Permission.VIEW_CHANNEL,
- Permission.VIEW_AUDIT_LOGS,
- Permission.MANAGE_SERVER,
- Permission.MESSAGE_SEND,
- Permission.MESSAGE_SEND_IN_THREADS,
- Permission.MESSAGE_EMBED_LINKS,
- Permission.MESSAGE_HISTORY
- );
-
@Inject
public DebugCommandHandler(@NonNull AuditLogRegistrationClient auditLogRegistrationClient, @NonNull MessageLogRegistrationClient messageLogRegistrationClient, @NonNull PaperTrailConfig paperTrailConfig) {
this.auditLogRegistrationClient = auditLogRegistrationClient;
@@ -92,10 +80,10 @@ private String formatPermissions(@NonNull EnumSet grantedGuildOrChan
// 2) RETAIN those GRANTED PERMISSIONS that match with the NECESSARY ONES
// there may be cases where GRANTED PERMISSIONS is NOT a perfect SUPERSET of NECESSARY PERMISSIONS
// this indicates that some NECESSARY PERMISSIONS have been DENIED
- grantedPermissions.retainAll(necessaryPermissions);
+ grantedPermissions.retainAll(PermissionUtils.necessaryPermissions());
// create a copy of necessary permissions
- EnumSet deniedPermissions = EnumSet.copyOf(necessaryPermissions);
+ EnumSet deniedPermissions = EnumSet.copyOf(PermissionUtils.necessaryPermissions());
// now if you calculate necessary - granted, you will get the set of necessary permissions which are DENIED
deniedPermissions.removeAll(grantedPermissions);
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 7e373dd..faea722 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
@@ -89,6 +89,10 @@ public void onChannelCreate(@NonNull GuildAuditLogEntryCreateEvent event) {
// the second two are forum only cases which stay empty during creation
}
+ case "topic" -> eb.addField(MarkdownUtil.underline("Channel Topic"), "╰┈➤" + newValue, false);
+
+ case "rtc_region" -> eb.addField(MarkdownUtil.underline("RTC Region"), "╰┈➤" + newValue, false);
+
default -> {
eb.addField("Unimplemented Change Key", changeKey, false);
log.info("Unimplemented Change Key for Channel Create: {}\nOLD_VALUE: {}\nNEW_VALUE: {}", changeKey, oldValue, newValue);
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 dab9983..234fada 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
@@ -122,6 +122,15 @@ public void onGuildUpdate(@NonNull GuildAuditLogEntryCreateEvent event) {
case "explicit_content_filter" ->
eb.addField(MarkdownUtil.underline("Explicit Content Filter"), "╰┈➤" + GuildUtils.resolveExplicitContentFilterLevel(newValue), false);
+ case "theme" ->
+ eb.addField(MarkdownUtil.underline("Server Theme"), "╰┈➤ Server Theme has been updated", false);
+
+ case "splash_hash" ->
+ eb.addField(MarkdownUtil.underline("Server Splash"), "╰┈➤ Server Splash image has been updated", false);
+
+ case "banner_hash" ->
+ eb.addField(MarkdownUtil.underline("Server Banner"), "╰┈➤ Server Banner image has been updated", false);
+
default -> {
eb.addField("Unimplemented Change Key", changeKey, false);
log.info("Unimplemented Change Key for Guild Update: {}\nOLD_VALUE: {}\nNEW_VALUE: {}", changeKey, oldValue, newValue);
diff --git a/src/main/java/io/github/eggy03/papertrail/bot/utils/PermissionUtils.java b/src/main/java/io/github/eggy03/papertrail/bot/utils/PermissionUtils.java
new file mode 100644
index 0000000..4c4e970
--- /dev/null
+++ b/src/main/java/io/github/eggy03/papertrail/bot/utils/PermissionUtils.java
@@ -0,0 +1,21 @@
+package io.github.eggy03.papertrail.bot.utils;
+
+import lombok.NonNull;
+import lombok.experimental.UtilityClass;
+import net.dv8tion.jda.api.Permission;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+@UtilityClass
+public final class PermissionUtils {
+
+ @NonNull
+ public Set necessaryPermissions() {
+ return EnumSet.of(
+ Permission.VIEW_CHANNEL, Permission.VIEW_AUDIT_LOGS, Permission.MANAGE_SERVER,
+ Permission.MESSAGE_SEND, Permission.MESSAGE_SEND_IN_THREADS, Permission.MESSAGE_EMBED_LINKS,
+ Permission.MESSAGE_HISTORY
+ );
+ }
+}
diff --git a/src/main/java/io/github/eggy03/papertrail/bot/utils/auditlog/MessageUtils.java b/src/main/java/io/github/eggy03/papertrail/bot/utils/auditlog/MessageUtils.java
index b93b493..8fda6a9 100644
--- a/src/main/java/io/github/eggy03/papertrail/bot/utils/auditlog/MessageUtils.java
+++ b/src/main/java/io/github/eggy03/papertrail/bot/utils/auditlog/MessageUtils.java
@@ -3,13 +3,17 @@
import io.github.eggy03.papertrail.bot.utils.NumberParseUtils;
import lombok.NonNull;
import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.events.guild.GenericGuildEvent;
+import net.dv8tion.jda.api.exceptions.ErrorResponseException;
+import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import org.jetbrains.annotations.Blocking;
import org.jetbrains.annotations.Nullable;
@UtilityClass
+@Slf4j
public final class MessageUtils {
private static final String FALLBACK_STRING = "N/A";
@@ -28,10 +32,14 @@ public static String resolveMessageJumpUrlFromId(@Nullable Object channelId, @Nu
return FALLBACK_STRING;
// Blocking REST Action
- Message message = textChannel.retrieveMessageById(messageIdLong).complete();
- if (message == null)
- return FALLBACK_STRING;
+ // read retrieveMessageById doc for try catch explanation
+ try {
+ Message message = textChannel.retrieveMessageById(messageIdLong).complete();
+ return message.getJumpUrl();
+ } catch (InsufficientPermissionException | ErrorResponseException e) {
+ log.debug("Error while retrieving message by ID", e);
+ return "Unable to resolve the message jump URL due to insufficient permissions or access.";
+ }
- return message.getJumpUrl();
}
}