package cc.fascinated.bat.features.birthday; import cc.fascinated.bat.features.Feature; import cc.fascinated.bat.features.birthday.command.BirthdayCommand; import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.service.CommandService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @author Fascinated (fascinated7) */ @Component public class BirthdayFeature extends Feature { private final GuildService guildService; public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) { super("Birthday", Category.GENERAL); this.guildService = guildService; commandService.registerCommand(context.getBean(BirthdayCommand.class)); } /** * Check birthdays every day at midnight */ @Scheduled(cron = "0 0 0 * * *") private void checkBirthdays() { for (BatGuild guild : guildService.getAllGuilds()) { BirthdayProfile profile = guild.getProfile(BirthdayProfile.class); profile.checkBirthdays(guild); } } }