package cc.fascinated.bat.service; import cc.fascinated.bat.features.Feature; import lombok.Getter; import lombok.NonNull; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author Fascinated (fascinated7) */ @Service @Getter @Log4j2 @DependsOn("commandService") public class FeatureService { /** * The registered features */ private final List features = new ArrayList<>(); @Autowired public FeatureService(@NonNull ApplicationContext context, @NonNull CommandService commandService) { context.getBeansOfType(Feature.class) .values() .forEach((feature) -> { features.add(context.getBean(feature.getClass())); }); commandService.registerSlashCommands(); // Register all slash commands } }