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); + } } }