From a605ab2dbae08fbd8f748b1ccea2d29493f2603f Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 5 Jul 2024 21:47:29 +0100 Subject: [PATCH] fix some logging things --- .../logging/listeners/MemberListener.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/logging/listeners/MemberListener.java b/src/main/java/cc/fascinated/bat/features/logging/listeners/MemberListener.java index 36f06d0..ecad0e1 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/listeners/MemberListener.java +++ b/src/main/java/cc/fascinated/bat/features/logging/listeners/MemberListener.java @@ -80,14 +80,17 @@ public class MemberListener implements EventListener { if (user.getDiscordUser().isBot()) { return; } - log.info("User \"{}\" changed their nickname from \"{}\" to \"{}\" in the guild \"{}\"", user.getName(), oldName, newName, guild.getDiscordGuild().getName()); + String oldNameFormatted = oldName == null ? user.getName() : oldName; + String newNameFormatted = newName == null ? user.getName() : newName; + log.info("User \"{}\" changed their nickname from \"{}\" to \"{}\" in the guild \"{}\"", + user.getName(), oldNameFormatted, newNameFormatted, guild.getDiscordGuild().getName()); logFeature.sendLog(guild, LogType.MEMBER_NICKNAME_UPDATE, EmbedUtils.genericEmbed() .setDescription(new EmbedDescriptionBuilder("Member Nickname Updated") .appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) .appendLine("Nickname: `%s` -> `%s`".formatted( - oldName == null ? user.getName() : oldName, - newName == null ? user.getName() : newName + oldNameFormatted, + newNameFormatted ), true) .build()) .build()); @@ -98,7 +101,9 @@ public class MemberListener implements EventListener { if (user.getDiscordUser().isBot()) { return; } - log.info("User \"{}\" changed their global name from \"{}\" to \"{}\"", user.getName(), oldName, newName); + String oldNameFormatted = oldName == null ? user.getName() : oldName; + String newNameFormatted = newName == null ? user.getName() : newName; + log.info("User \"{}\" changed their global name from \"{}\" to \"{}\"", user.getName(), oldNameFormatted, newNameFormatted); for (Guild guild : DiscordService.JDA.getGuilds()) { BatGuild batGuild = guildService.getGuild(guild.getId()); @@ -109,8 +114,8 @@ public class MemberListener implements EventListener { .setDescription(new EmbedDescriptionBuilder("Member Name Updated") .appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) .appendLine("Name: `%s` -> `%s`".formatted( - oldName == null ? user.getName() : oldName, - newName == null ? user.getName() : newName + oldNameFormatted, + newNameFormatted ), true) .build()) .build()); @@ -153,7 +158,7 @@ public class MemberListener implements EventListener { logFeature.sendLog(batGuild, LogType.MEMBER_USERNAME_UPDATE, EmbedUtils.genericEmbed() .setDescription(new EmbedDescriptionBuilder("Member Avatar Updated") .appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) - .appendLine("Avatar: %s".formatted(newAvatarUrl == null ? "Removed" : "[avatar](%s)".formatted(newAvatarUrl)), true) + .appendLine("Avatar: %s".formatted(newAvatarUrl == null ? "Removed" : "[click here](%s)".formatted(newAvatarUrl)), true) .build()) .setThumbnail(newAvatarUrl) .build());