only check guilds that we're in

This commit is contained in:
Lee 2024-07-01 15:16:06 +01:00
parent c93e112ebf
commit be7f8a9057

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