From be7f8a9057a6c8f926c24a2481368921241d228b Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 1 Jul 2024 15:16:06 +0100 Subject: [PATCH] only check guilds that we're in --- .../bat/features/birthday/BirthdayFeature.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 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 8dfb731..f1cff17 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/BirthdayFeature.java @@ -8,8 +8,10 @@ import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.service.CommandService; +import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; +import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.Scheduled; @@ -40,9 +42,14 @@ public class BirthdayFeature extends Feature implements EventListener { */ @Scheduled(cron = "0 1 0 * * *") private void checkBirthdays() { - for (BatGuild guild : guildService.getGuilds().values()) { - BirthdayProfile profile = guild.getBirthdayProfile(); - profile.checkBirthdays(guild); + for (Guild guild : DiscordService.JDA.getGuilds()) { + BatGuild batGuild = guildService.getGuild(guild.getId()); + if (batGuild == null) { + continue; + } + BirthdayProfile profile = batGuild.getBirthdayProfile(); + profile.checkBirthdays(batGuild); + } } }