cleanup
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m42s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m42s
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
package cc.fascinated.bat.birthday;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.common.feature.Feature;
|
||||
import cc.fascinated.bat.common.feature.FeatureProfile;
|
||||
import cc.fascinated.bat.birthday.command.BirthdayCommand;
|
||||
import cc.fascinated.bat.birthday.profile.BirthdayProfile;
|
||||
import cc.fascinated.bat.common.model.BatGuild;
|
||||
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 org.springframework.context.ApplicationContext;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
public class BirthdayFeature extends Feature implements EventListener {
|
||||
private final GuildService guildService;
|
||||
|
||||
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
||||
super("Birthday", FeatureProfile.FeatureState.DISABLED, true);
|
||||
this.guildService = guildService;
|
||||
|
||||
registerCommand(commandService, context.getBean(BirthdayCommand.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check birthdays every day at midnight
|
||||
*/
|
||||
@Scheduled(cron = "0 1 0 * * *")
|
||||
private void checkBirthdays() {
|
||||
for (Guild guild : DiscordService.JDA.getGuilds()) {
|
||||
BatGuild batGuild = guildService.getGuild(guild.getId());
|
||||
if (batGuild.getFeatureProfile().isFeatureDisabled(this)) { // Check if the feature is disabled
|
||||
continue;
|
||||
}
|
||||
BirthdayProfile profile = batGuild.getBirthdayProfile();
|
||||
profile.checkBirthdays(batGuild);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user