From ec54d5427e1146f14f06f18623e214ea887fc12f Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 5 Jul 2024 23:35:41 +0100 Subject: [PATCH] update interaction error message --- .../cc/fascinated/bat/common/EmbedUtils.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java index 7d86ba4..09b5bfa 100644 --- a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java +++ b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java @@ -48,25 +48,26 @@ public class EmbedUtils { /** * Builds a generic interaction error embed * - * @param ex the exception + * @param ex the exceptionk * @return the embed builder */ public static EmbedBuilder genericInteractionError(Exception ex) { TextChannel channel = ChannelUtils.getTextChannel(Config.INSTANCE.getLogsChannel()); - if (channel != null) { - channel.sendMessageEmbeds(EmbedUtils.errorEmbed() - .setDescription(""" - An error has occurred while processing an interaction. Please check the logs for more information. - ```java - %s - ```""".formatted(ex.getLocalizedMessage())) - .build()).queue(); - } - return EmbedUtils.errorEmbed() + EmbedBuilder embed = errorEmbed() .setDescription(""" - An error has occurred while processing your interaction. Please check the logs for more information. - ```java - %s - ```""".formatted(ex.getLocalizedMessage())); + An error has occurred while processing %s interaction. If this issue persists, please contact the developers. + Cause: `%s` + ```java + %s + ```""".formatted( + channel == null ? "an" : "your", + ex.getStackTrace()[0].getClassName(), + ex.getLocalizedMessage() + )); + + if (channel != null) { + channel.sendMessageEmbeds(embed.build()).queue(); + } + return embed; } }