forked from Fascinated/Bat
cleanup commands
This commit is contained in:
36
src/main/java/cc/fascinated/bat/service/FeatureService.java
Normal file
36
src/main/java/cc/fascinated/bat/service/FeatureService.java
Normal file
@ -0,0 +1,36 @@
|
||||
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<Feature> 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user