From c1f9bfec6a33556cae2ebd08ed76e215488d0381 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 1 Jul 2024 15:20:49 +0100 Subject: [PATCH] don't remove birthdays for members that have left --- .../features/birthday/BirthdayFeature.java | 7 ------ .../birthday/profile/BirthdayProfile.java | 25 +------------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java b/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java index f1cff17..b79ef6c 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java @@ -31,12 +31,6 @@ public class BirthdayFeature extends Feature implements EventListener { registerCommand(commandService, context.getBean(BirthdayCommand.class)); } - @Override - public void onGuildMemberLeave(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberRemoveEvent event) { - BirthdayProfile profile = guild.getBirthdayProfile(); - profile.removeBirthday(user.getId()); - } - /** * Check birthdays every day at midnight */ @@ -49,7 +43,6 @@ public class BirthdayFeature extends Feature implements EventListener { } BirthdayProfile profile = batGuild.getBirthdayProfile(); profile.checkBirthdays(batGuild); - } } } diff --git a/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java b/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java index f655610..bf0aa9d 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java @@ -96,33 +96,10 @@ public class BirthdayProfile extends Serializable { if (birthdays == null) { birthdays = new HashMap<>(); } - - List toRemove = new ArrayList<>(); - Guild discordGuild = guild.getDiscordGuild(); - for (Map.Entry entry : birthdays.entrySet()) { - String userId = entry.getKey(); - Date birthday = entry.getValue().getBirthday(); - - if (userId == null || birthday == null) { // this should never happen - continue; - } - - // Check if the user is still in the guild, if not remove them - Member member = discordGuild.getMemberById(userId); - if (member == null) { - toRemove.add(userId); - } - } - - for (String userId : toRemove) { - birthdays.remove(userId); - } - if (channelId == null) { return false; } - - if (discordGuild.getTextChannelById(channelId) == null) { + if (guild.getDiscordGuild().getTextChannelById(channelId) == null) { channelId = null; return false; }