cleanup features and move all misc commands into a base feature
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 48s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 48s
This commit is contained in:
parent
5b1ddb145f
commit
ea546f02ca
@ -20,6 +20,11 @@ public abstract class Feature {
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The description of the feature
|
||||
*/
|
||||
public final boolean canBeDisabled;
|
||||
|
||||
/**
|
||||
* The category of the feature
|
||||
*/
|
||||
@ -32,7 +37,10 @@ public abstract class Feature {
|
||||
* @param command The command to register
|
||||
*/
|
||||
public void registerCommand(@NonNull CommandService commandService, @NonNull BatCommand command) {
|
||||
command.setCategory(category);
|
||||
// If the command using the default category then set the category to the feature's category
|
||||
if (command.getCategory() == Category.GENERAL) {
|
||||
command.setCategory(this.category);
|
||||
}
|
||||
command.setFeature(this);
|
||||
commandService.registerCommand(command);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AfkFeature extends Feature {
|
||||
public AfkFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("AFK", Category.GENERAL);
|
||||
super("AFK", true, Category.GENERAL);
|
||||
|
||||
registerCommand(commandService, context.getBean(AfkCommand.class));
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
public class AutoRoleFeature extends Feature {
|
||||
@Autowired
|
||||
public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("Auto Role", Category.SERVER);
|
||||
super("Auto Role",true, Category.SERVER);
|
||||
|
||||
registerCommand(commandService, context.getBean(AutoRoleCommand.class));
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package cc.fascinated.bat.features.base;
|
||||
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand;
|
||||
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.*;
|
||||
import cc.fascinated.bat.features.base.commands.general.avatar.AvatarCommand;
|
||||
import cc.fascinated.bat.features.base.commands.general.banner.BannerCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.MemberCountCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.PremiumCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.channel.ChannelCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
public class BaseFeature extends Feature {
|
||||
@Autowired
|
||||
public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("Base", false, Category.GENERAL);
|
||||
|
||||
super.registerCommand(commandService, context.getBean(PremiumCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(MemberCountCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(ChannelCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(VoteCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(PingCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(InviteCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(HelpCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(BotStatsCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(BannerCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(AvatarCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(ImageCommand.class));
|
||||
super.registerCommand(commandService, context.getBean(FeatureCommand.class));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.botadmin.premium;
|
||||
package cc.fascinated.bat.features.base.commands.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.botadmin.premium;
|
||||
package cc.fascinated.bat.features.base.commands.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.botadmin.premium;
|
||||
package cc.fascinated.bat.features.base.commands.botadmin.premium;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.fun.image;
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.fun.image;
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.fun.image;
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.fun.image;
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.fun.image;
|
||||
package cc.fascinated.bat.features.base.commands.fun.image;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.Consts;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.Consts;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general;
|
||||
package cc.fascinated.bat.features.base.commands.general;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.avatar;
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.avatar;
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.avatar;
|
||||
package cc.fascinated.bat.features.base.commands.general.avatar;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.banner;
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.banner;
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.general.banner;
|
||||
package cc.fascinated.bat.features.base.commands.general.banner;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server;
|
||||
package cc.fascinated.bat.features.base.commands.server;
|
||||
|
||||
import cc.fascinated.bat.Emojis;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server;
|
||||
package cc.fascinated.bat.features.base.commands.server;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server.channel;
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server.channel;
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server.channel;
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,4 +1,4 @@
|
||||
package cc.fascinated.bat.command.impl.server.channel;
|
||||
package cc.fascinated.bat.features.base.commands.server.channel;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.command;
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
||||
@ -50,6 +50,13 @@ public class DisableSubCommand extends BatSubCommand {
|
||||
return;
|
||||
}
|
||||
Feature feature = FeatureService.INSTANCE.getFeature(featureName);
|
||||
if (!feature.isCanBeDisabled()) {
|
||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("The feature `%s` cannot be disabled".formatted(feature.getName()))
|
||||
.build()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
if (featureProfile.isFeatureDisabled(feature)) {
|
||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("The feature `%s` is already disabled".formatted(feature.getName()))
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.command;
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features.command;
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
@ -12,7 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "feature", description = "Configure features in your guild", requiredPermissions = Permission.ADMINISTRATOR)
|
||||
@CommandInfo(name = "feature", description = "Configure features in your guild", requiredPermissions = Permission.ADMINISTRATOR, category = Category.SERVER)
|
||||
public class FeatureCommand extends BatCommand {
|
||||
@Autowired
|
||||
public FeatureCommand(@NonNull ApplicationContext context) {
|
@ -1,10 +1,10 @@
|
||||
package cc.fascinated.bat.features.command;
|
||||
package cc.fascinated.bat.features.base.commands.server.feature;
|
||||
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.FeatureService;
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated.bat.features;
|
||||
package cc.fascinated.bat.features.base.profile;
|
||||
|
||||
import cc.fascinated.bat.common.Profile;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -23,7 +23,7 @@ public class BirthdayFeature extends Feature implements EventListener {
|
||||
private final GuildService guildService;
|
||||
|
||||
public BirthdayFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService, @NonNull GuildService guildService) {
|
||||
super("Birthday", Category.UTILITY);
|
||||
super("Birthday", true, Category.UTILITY);
|
||||
this.guildService = guildService;
|
||||
|
||||
registerCommand(commandService, context.getBean(BirthdayCommand.class));
|
||||
|
@ -2,6 +2,11 @@ package cc.fascinated.bat.features.namehistory;
|
||||
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.namehistory.command.NameHistoryCommand;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -11,7 +16,10 @@ import org.springframework.stereotype.Component;
|
||||
public class NameHistoryFeature extends Feature {
|
||||
public static final int NAME_HISTORY_SIZE = 25;
|
||||
|
||||
public NameHistoryFeature() {
|
||||
super("Name History", Category.UTILITY);
|
||||
@Autowired
|
||||
public NameHistoryFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("Name History", true,Category.UTILITY);
|
||||
|
||||
super.registerCommand(commandService, context.getBean(NameHistoryCommand.class));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
public class ScoreSaberFeature extends Feature {
|
||||
@Autowired
|
||||
public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("ScoreSaber", Category.BEAT_SABER);
|
||||
super("ScoreSaber", true, Category.BEAT_SABER);
|
||||
|
||||
registerCommand(commandService, context.getBean(ScoreSaberCommand.class));
|
||||
registerCommand(commandService, context.getBean(UserFeedCommand.class));
|
||||
|
@ -6,13 +6,16 @@ import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.SpotifyUtils;
|
||||
import cc.fascinated.bat.exception.BatException;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.spotify.command.SpotifyCommand;
|
||||
import cc.fascinated.bat.features.spotify.profile.SpotifyProfile;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.CommandService;
|
||||
import cc.fascinated.bat.service.SpotifyService;
|
||||
import lombok.NonNull;
|
||||
import lombok.SneakyThrows;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
import se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying;
|
||||
import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified;
|
||||
@ -25,8 +28,10 @@ import se.michaelthelin.spotify.model_objects.specification.Track;
|
||||
@Component
|
||||
public class SpotifyFeature extends Feature {
|
||||
@Autowired
|
||||
public SpotifyFeature() {
|
||||
super("Spotify", Category.MUSIC);
|
||||
public SpotifyFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
||||
super("Spotify", true,Category.MUSIC);
|
||||
|
||||
super.registerCommand(commandService, context.getBean(SpotifyCommand.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.model;
|
||||
|
||||
import cc.fascinated.bat.common.ProfileHolder;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
||||
import cc.fascinated.bat.features.namehistory.profile.guild.NameHistoryProfile;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import lombok.*;
|
||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.Consts;
|
||||
import cc.fascinated.bat.command.*;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.config.Config;
|
||||
import cc.fascinated.bat.features.FeatureProfile;
|
||||
import cc.fascinated.bat.features.base.profile.FeatureProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.Getter;
|
||||
|
@ -2,7 +2,7 @@ package cc.fascinated.bat.service;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.features.Feature;
|
||||
import cc.fascinated.bat.features.command.FeatureCommand;
|
||||
import cc.fascinated.bat.features.base.commands.server.feature.FeatureCommand;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@ -50,7 +50,9 @@ public class FeatureService {
|
||||
context.getBeansOfType(BatCommand.class)
|
||||
.values()
|
||||
.forEach((command) -> {
|
||||
commandService.registerCommand(context.getBean(command.getClass()));
|
||||
if (command.getFeature() == null) {
|
||||
log.error("Command \"{}\" does not belong to a feature, not registering it...", command.getCommandInfo().name());
|
||||
}
|
||||
});
|
||||
|
||||
commandService.registerCommand(context.getBean(FeatureCommand.class));
|
||||
|
Loading…
x
Reference in New Issue
Block a user