don't show old avatar url and make the thumbnail of the log the new avatar
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s

This commit is contained in:
Lee 2024-07-04 07:03:48 +01:00
parent dc04a2f36a
commit 43c5473a4f

@ -30,13 +30,13 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.List;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Log4j2 @Component
@Log4j2
public class MemberListener implements EventListener { public class MemberListener implements EventListener {
private final LogFeature logFeature; private final LogFeature logFeature;
private final GuildService guildService; private final GuildService guildService;
@ -50,7 +50,7 @@ public class MemberListener implements EventListener {
@Override @Override
public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) { public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) {
if (user.getDiscordUser().isBot()) if (user.getDiscordUser().isBot())
log.info("User \"{}\" joined the guild \"{}\"", user.getName(), guild.getDiscordGuild().getName()); log.info("User \"{}\" joined the guild \"{}\"", user.getName(), guild.getDiscordGuild().getName());
logFeature.sendLog(guild, LogType.MEMBER_JOIN, EmbedUtils.successEmbed() logFeature.sendLog(guild, LogType.MEMBER_JOIN, EmbedUtils.successEmbed()
.setDescription(new EmbedDescriptionBuilder("Member Joined") .setDescription(new EmbedDescriptionBuilder("Member Joined")
@ -58,7 +58,7 @@ public class MemberListener implements EventListener {
.appendLine("Username: `%s`".formatted(user.getDiscordUser().getName()), true) .appendLine("Username: `%s`".formatted(user.getDiscordUser().getName()), true)
.appendLine("Joined Discord: <t:%s:R>".formatted(user.getDiscordUser().getTimeCreated().toEpochSecond()), true) .appendLine("Joined Discord: <t:%s:R>".formatted(user.getDiscordUser().getTimeCreated().toEpochSecond()), true)
.build()) .build())
.setThumbnail(user.getDiscordUser().getEffectiveAvatarUrl()) .setThumbnail(user.getDiscordUser().getEffectiveAvatarUrl())
.build()); .build());
} }
@ -150,9 +150,10 @@ 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("Old Avatar: %s".formatted(oldAvatarUrl == null ? "None" : "[avatar](%s)".formatted(oldAvatarUrl)), true) // .appendLine("Old Avatar: %s".formatted(oldAvatarUrl == null ? "None" : "[avatar](%s)".formatted(oldAvatarUrl)), true)
.appendLine("New Avatar: [avatar](%s)".formatted(newAvatarUrl), true) .appendLine("New Avatar: [avatar](%s)".formatted(newAvatarUrl), true)
.build()) .build())
.setThumbnail(newAvatarUrl)
.build()); .build());
} }
} }
@ -245,7 +246,7 @@ public class MemberListener implements EventListener {
@Override @Override
public void onGuildMemberBoostAdd(@NonNull BatGuild guild, @NonNull BatUser user, OffsetDateTime oldBoostTime, public void onGuildMemberBoostAdd(@NonNull BatGuild guild, @NonNull BatUser user, OffsetDateTime oldBoostTime,
@NonNull OffsetDateTime newBoostTime, @NonNull GuildMemberUpdateBoostTimeEvent event) { @NonNull OffsetDateTime newBoostTime, @NonNull GuildMemberUpdateBoostTimeEvent event) {
if (user.getDiscordUser().isBot()) { if (user.getDiscordUser().isBot()) {
return; return;
} }