fix some logging things

This commit is contained in:
Lee 2024-07-05 21:47:29 +01:00
parent 863206bb9f
commit a605ab2dba

@ -80,14 +80,17 @@ public class MemberListener implements EventListener {
if (user.getDiscordUser().isBot()) { if (user.getDiscordUser().isBot()) {
return; 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() logFeature.sendLog(guild, LogType.MEMBER_NICKNAME_UPDATE, EmbedUtils.genericEmbed()
.setDescription(new EmbedDescriptionBuilder("Member Nickname Updated") .setDescription(new EmbedDescriptionBuilder("Member Nickname Updated")
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) .appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
.appendLine("Nickname: `%s` -> `%s`".formatted( .appendLine("Nickname: `%s` -> `%s`".formatted(
oldName == null ? user.getName() : oldName, oldNameFormatted,
newName == null ? user.getName() : newName newNameFormatted
), true) ), true)
.build()) .build())
.build()); .build());
@ -98,7 +101,9 @@ public class MemberListener implements EventListener {
if (user.getDiscordUser().isBot()) { if (user.getDiscordUser().isBot()) {
return; 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()) { for (Guild guild : DiscordService.JDA.getGuilds()) {
BatGuild batGuild = guildService.getGuild(guild.getId()); BatGuild batGuild = guildService.getGuild(guild.getId());
@ -109,8 +114,8 @@ public class MemberListener implements EventListener {
.setDescription(new EmbedDescriptionBuilder("Member Name Updated") .setDescription(new EmbedDescriptionBuilder("Member Name Updated")
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) .appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
.appendLine("Name: `%s` -> `%s`".formatted( .appendLine("Name: `%s` -> `%s`".formatted(
oldName == null ? user.getName() : oldName, oldNameFormatted,
newName == null ? user.getName() : newName newNameFormatted
), true) ), true)
.build()) .build())
.build()); .build());
@ -153,7 +158,7 @@ public class MemberListener implements EventListener {
logFeature.sendLog(batGuild, LogType.MEMBER_USERNAME_UPDATE, EmbedUtils.genericEmbed() logFeature.sendLog(batGuild, LogType.MEMBER_USERNAME_UPDATE, EmbedUtils.genericEmbed()
.setDescription(new EmbedDescriptionBuilder("Member Avatar Updated") .setDescription(new EmbedDescriptionBuilder("Member Avatar Updated")
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true) .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()) .build())
.setThumbnail(newAvatarUrl) .setThumbnail(newAvatarUrl)
.build()); .build());