cleanup commands

This commit is contained in:
Lee 2024-06-27 19:36:52 +01:00
parent 3d39fd9784
commit f062fa21c3
35 changed files with 162 additions and 145 deletions

@ -3,7 +3,6 @@ package cc.fascinated.bat.command;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
@ -19,78 +18,45 @@ import java.util.Map;
@Getter @Setter @Getter @Setter
public abstract class BatCommand implements BatCommandExecutor { public abstract class BatCommand implements BatCommandExecutor {
/** /**
* The category of the command * The information about the command
*/ */
private Category category; private final CommandInfo commandInfo;
/**
* The name of the command
*/
private final String name;
/**
* The description of the command
*/
private final String description;
/** /**
* The command data for the slash command * The command data for the slash command
*/ */
private final CommandDataImpl commandData; private final CommandDataImpl commandData;
/**
* The required permissions for the command
*/
private final List<Permission> requiredPermissions;
/** /**
* The sub commands of the command * The sub commands of the command
*/ */
private final Map<String, BatSubCommand> subCommands = new HashMap<>(); private final Map<String, BatSubCommand> subCommands = new HashMap<>();
/** /**
* The commands snowflake from Discord * The category of the command
*/
private Category category;
/**
* The command snowflake from Discord
*/ */
private long commandSnowflake; private long commandSnowflake;
public BatCommand(@NonNull Category category, @NonNull String name, @NonNull String description, boolean guildOnly, Permission... permissions) { public BatCommand() {
this.category = category; this.commandInfo = getClass().getAnnotation(CommandInfo.class);
this.name = name; this.category = this.commandInfo.category();
this.description = description;
this.requiredPermissions = List.of(permissions);
this.commandData = new CommandDataImpl(this.name, description) this.commandData = new CommandDataImpl(this.commandInfo.name(), this.commandInfo.description())
.setGuildOnly(guildOnly); .setGuildOnly(this.commandInfo.guildOnly());
}
public BatCommand(@NonNull Category category, @NonNull String name) {
this(category, name, "No description provided.", false);
}
public BatCommand(@NonNull Category category, @NonNull String name, @NonNull String description) {
this(category, name, description, false);
}
public BatCommand(@NonNull String name, @NonNull String description, boolean guildOnly, Permission... permissions) {
this(Category.GENERAL, name, description, guildOnly, permissions);
}
public BatCommand(@NonNull String name) {
this(Category.GENERAL, name, "No description provided.", false);
}
public BatCommand(@NonNull String name, @NonNull String description) {
this(Category.GENERAL, name, description, false);
} }
/** /**
* Adds a sub command to the command * Adds a sub command to the command
* *
* @param name The name of the sub command
* @param subCommand The sub command * @param subCommand The sub command
*/ */
public void addSubCommand(@NonNull String name, @NonNull BatSubCommand subCommand) { public void addSubCommand(@NonNull BatSubCommand subCommand) {
this.subCommands.put(name.toLowerCase(), subCommand); this.subCommands.put(subCommand.getCommandInfo().name().toLowerCase(), subCommand);
this.commandData.addSubcommands(subCommand.getCommandData()); this.commandData.addSubcommands(subCommand.getCommandData());
} }

@ -2,35 +2,32 @@ package cc.fascinated.bat.command;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
import java.util.List;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Getter @Setter @Getter @Setter
public class BatSubCommand implements BatCommandExecutor { public class BatSubCommand implements BatCommandExecutor {
/**
* The information about the sub command
*/
private final CommandInfo commandInfo;
/** /**
* The command data for the slash command * The command data for the slash command
*/ */
private final SubcommandData commandData; private final SubcommandData commandData;
/**
* The required permissions for the command
*/
private final List<Permission> requiredPermissions;
/** /**
* The commands snowflake from Discord * The commands snowflake from Discord
*/ */
private long commandSnowflake; private long commandSnowflake;
public BatSubCommand(String name, String description, Permission... permissions) { public BatSubCommand() {
this.commandData = new SubcommandData(name, description); this.commandInfo = getClass().getAnnotation(CommandInfo.class);
this.requiredPermissions = List.of(permissions); this.commandData = new SubcommandData(this.commandInfo.name(), this.commandInfo.description());
} }
/** /**

@ -1,15 +1,11 @@
package cc.fascinated.bat.command; package cc.fascinated.bat.command;
/**
* @author Fascinated (fascinated7)
*/
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.entities.emoji.Emoji;
/** /**
* The category of the command * @author Fascinated (fascinated7)
*/ */
@AllArgsConstructor @Getter @AllArgsConstructor @Getter
public enum Category { public enum Category {

@ -0,0 +1,50 @@
package cc.fascinated.bat.command;
import net.dv8tion.jda.api.Permission;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author Fascinated (fascinated7)
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface CommandInfo {
/**
* The name of the command
*
* @return the name of the command
*/
String name();
/**
* The description of the command
*
* @return the description of the command
*/
String description() default "No description provided.";
/**
* If the command is guild only
*
* @return if the command is guild only
*/
boolean guildOnly() default true;
/**
* The required permissions for the command
*
* @return the required permissions for the command
*/
Permission[] requiredPermissions() default {};
/**
* The category of the command
*
* @return the category of the command
*/
Category category() default Category.GENERAL;
}

@ -1,6 +1,7 @@
package cc.fascinated.bat.command.impl; package cc.fascinated.bat.command.impl;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
@ -17,9 +18,9 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "avatar", description = "Get the avatar of a user")
public class AvatarCommand extends BatCommand { public class AvatarCommand extends BatCommand {
public AvatarCommand() { public AvatarCommand() {
super("avatar", "Gets the avatar of a user");
super.addOption(OptionType.USER, "user", "The user to get the avatar of", true); super.addOption(OptionType.USER, "user", "The user to get the avatar of", true);
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.command.impl; package cc.fascinated.bat.command.impl;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TimeUtils; import cc.fascinated.bat.common.TimeUtils;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -23,6 +24,7 @@ import java.lang.management.RuntimeMXBean;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "botstats", description = "Shows the bot statistics")
public class BotStatsCommand extends BatCommand { public class BotStatsCommand extends BatCommand {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
private final GuildService guildService; private final GuildService guildService;
@ -30,7 +32,6 @@ public class BotStatsCommand extends BatCommand {
@Autowired @Autowired
public BotStatsCommand(@NonNull GuildService guildService, @NonNull UserService userService) { public BotStatsCommand(@NonNull GuildService guildService, @NonNull UserService userService) {
super("botstats", "Shows the bot statistics");
this.guildService = guildService; this.guildService = guildService;
this.userService = userService; this.userService = userService;
} }

@ -4,6 +4,7 @@ import cc.fascinated.bat.Consts;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.Category;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.event.EventListener; import cc.fascinated.bat.event.EventListener;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -35,12 +36,12 @@ import java.util.Map;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "help", description = "View the bots command categories.")
public class HelpCommand extends BatCommand implements EventListener { public class HelpCommand extends BatCommand implements EventListener {
private final CommandService commandService; private final CommandService commandService;
@Autowired @Autowired
public HelpCommand(@NonNull CommandService commandService) { public HelpCommand(@NonNull CommandService commandService) {
super("help", "View the bots command categories.");
this.commandService = commandService; this.commandService = commandService;
} }
@ -74,7 +75,7 @@ public class HelpCommand extends BatCommand implements EventListener {
BatSubCommand subCommand = entry.getValue(); BatSubCommand subCommand = entry.getValue();
SubcommandData commandData = subCommand.getCommandData(); SubcommandData commandData = subCommand.getCommandData();
commands += "</%s %s:%s> - %s\n".formatted( commands += "</%s %s:%s> - %s\n".formatted(
command.getName(), command.getCommandInfo().name(),
commandData.getName(), commandData.getName(),
subCommand.getCommandSnowflake(), subCommand.getCommandSnowflake(),
commandData.getDescription() commandData.getDescription()
@ -83,9 +84,9 @@ public class HelpCommand extends BatCommand implements EventListener {
continue; continue;
} }
commands += "</%s:%s> - %s\n".formatted( commands += "</%s:%s> - %s\n".formatted(
command.getName(), command.getCommandInfo().name(),
command.getCommandSnowflake(), command.getCommandSnowflake(),
command.getDescription() command.getCommandInfo().description()
); );
} }
} }

@ -2,6 +2,7 @@ package cc.fascinated.bat.command.impl;
import cc.fascinated.bat.Consts; import cc.fascinated.bat.Consts;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
@ -15,11 +16,8 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "invite", description = "Invite the bot to your server!")
public class InviteCommand extends BatCommand { public class InviteCommand extends BatCommand {
public InviteCommand() {
super("invite", "Invite the bot to your server!");
}
@Override @Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
interaction.replyEmbeds(EmbedUtils.genericEmbed() interaction.replyEmbeds(EmbedUtils.genericEmbed()

@ -1,6 +1,7 @@
package cc.fascinated.bat.command.impl; package cc.fascinated.bat.command.impl;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.DiscordService;
@ -14,11 +15,8 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "ping", description = "Gets the ping of the bot")
public class PingCommand extends BatCommand { public class PingCommand extends BatCommand {
public PingCommand() {
super("ping", "Gets the ping of the bot");
}
@Override @Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

@ -2,6 +2,7 @@ package cc.fascinated.bat.command.impl.fun;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.Category;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,11 +18,8 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "cat", description = "Get a random cat image", category = Category.FUN)
public class CatCommand extends BatCommand { public class CatCommand extends BatCommand {
public CatCommand() {
super(Category.FUN, "cat", "Get a random cat image");
}
@Override @Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
CatImageToken[] responseEntity = WebRequest.getAsEntity("https://api.thecatapi.com/v1/images/search", CatImageToken[].class); CatImageToken[] responseEntity = WebRequest.getAsEntity("https://api.thecatapi.com/v1/images/search", CatImageToken[].class);

@ -2,6 +2,7 @@ package cc.fascinated.bat.command.impl.fun;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.Category; import cc.fascinated.bat.command.Category;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.WebRequest; import cc.fascinated.bat.common.WebRequest;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,11 +18,8 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "dog", description = "Get a random dog image", category = Category.FUN)
public class DogCommand extends BatCommand { public class DogCommand extends BatCommand {
public DogCommand() {
super(Category.FUN, "dog", "Get a random dog image");
}
@Override @Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
RandomImage responseEntity = WebRequest.getAsEntity("https://dog.ceo/api/breeds/image/random", RandomImage.class); RandomImage responseEntity = WebRequest.getAsEntity("https://dog.ceo/api/breeds/image/random", RandomImage.class);

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.afk.command; package cc.fascinated.bat.features.afk.command;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.MemberUtils; import cc.fascinated.bat.common.MemberUtils;
import cc.fascinated.bat.features.afk.profile.AfkProfile; import cc.fascinated.bat.features.afk.profile.AfkProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,9 +18,9 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "afk", description = "Sets your AFK status")
public class AfkCommand extends BatCommand { public class AfkCommand extends BatCommand {
public AfkCommand() { public AfkCommand() {
super("afk", "Sets your AFK status");
super.addOption(OptionType.STRING, "reason", "The reason for being AFK", false); super.addOption(OptionType.STRING, "reason", "The reason for being AFK", false);
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.autorole.command; package cc.fascinated.bat.features.autorole.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.RoleUtils; import cc.fascinated.bat.common.RoleUtils;
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
@ -21,12 +22,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("autoroles:add.sub") @Component("autoroles:add.sub")
@CommandInfo(name = "add", description = "Adds a role to the auto roles list")
public class AddSubCommand extends BatSubCommand { public class AddSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public AddSubCommand(@NonNull GuildService guildService) { public AddSubCommand(@NonNull GuildService guildService) {
super("add", "Adds a role to the auto roles list");
super.addOption(OptionType.ROLE, "role", "The role to add", true); super.addOption(OptionType.ROLE, "role", "The role to add", true);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.autorole.command; package cc.fascinated.bat.features.autorole.command;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import lombok.NonNull; import lombok.NonNull;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -10,13 +11,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("autoroles.command") @Component("autoroles.command")
@CommandInfo(name = "autorole", description = "Set up the automatic role system for members on join", requiredPermissions = Permission.MANAGE_SERVER)
public class AutoRoleCommand extends BatCommand { public class AutoRoleCommand extends BatCommand {
public AutoRoleCommand(@NonNull ApplicationContext context) { public AutoRoleCommand(@NonNull ApplicationContext context) {
super("autorole", "Set up the automatic role system for members on join", true, Permission.MANAGE_SERVER); super.addSubCommand(context.getBean(ListSubCommand.class));
super.addSubCommand(context.getBean(AddSubCommand.class));
super.addSubCommand("list", context.getBean(ListSubCommand.class)); super.addSubCommand(context.getBean(RemoveSubCommand.class));
super.addSubCommand("add", context.getBean(AddSubCommand.class)); super.addSubCommand(context.getBean(ClearSubCommand.class));
super.addSubCommand("remove", context.getBean(RemoveSubCommand.class));
super.addSubCommand("clear", context.getBean(ClearSubCommand.class));
} }
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.autorole.command; package cc.fascinated.bat.features.autorole.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,12 +18,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("autoroles:clear.sub") @Component("autoroles:clear.sub")
@CommandInfo(name = "clear", description = "Clears all auto roles")
public class ClearSubCommand extends BatSubCommand { public class ClearSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ClearSubCommand(GuildService guildService) { public ClearSubCommand(GuildService guildService) {
super("clear", "Clears all auto roles");
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.autorole.command; package cc.fascinated.bat.features.autorole.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -16,12 +17,8 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("autoroles:list.sub") @Component("autoroles:list.sub")
@CommandInfo(name = "list", description = "Lists all auto roles")
public class ListSubCommand extends BatSubCommand { public class ListSubCommand extends BatSubCommand {
public ListSubCommand() {
super("list", "Lists all auto roles");
}
@Override @Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
AutoRoleProfile profile = guild.getProfile(AutoRoleProfile.class); AutoRoleProfile profile = guild.getProfile(AutoRoleProfile.class);

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.autorole.command; package cc.fascinated.bat.features.autorole.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -20,12 +21,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("autoroles:remove.sub") @Component("autoroles:remove.sub")
@CommandInfo(name = "remove", description = "Removes a role from the auto roles list")
public class RemoveSubCommand extends BatSubCommand { public class RemoveSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public RemoveSubCommand(GuildService guildService) { public RemoveSubCommand(GuildService guildService) {
super("remove", "Removes a role from the auto roles list");
super.addOption(OptionType.ROLE, "role", "The role to remove", true); super.addOption(OptionType.ROLE, "role", "The role to remove", true);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.birthday.command; package cc.fascinated.bat.features.birthday.command;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import lombok.NonNull; import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -10,14 +11,13 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "birthday", description = "Modify your birthday settings.")
public class BirthdayCommand extends BatCommand { public class BirthdayCommand extends BatCommand {
@Autowired @Autowired
public BirthdayCommand(@NonNull ApplicationContext context) { public BirthdayCommand(@NonNull ApplicationContext context) {
super("birthday", "Modify your birthday settings.", true); super.addSubCommand(context.getBean(SetSubCommand.class));
super.addSubCommand(context.getBean(RemoveSubCommand.class));
super.addSubCommand("set", context.getBean(SetSubCommand.class)); super.addSubCommand(context.getBean(ChannelSubCommand.class));
super.addSubCommand("remove", context.getBean(RemoveSubCommand.class)); super.addSubCommand(context.getBean(MessageSubCommand.class));
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
super.addSubCommand("message", context.getBean(MessageSubCommand.class));
} }
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.birthday.command; package cc.fascinated.bat.features.birthday.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TextChannelUtils; import cc.fascinated.bat.common.TextChannelUtils;
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
@ -23,12 +24,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("birthday:channel.sub") @Component("birthday:channel.sub")
@CommandInfo(name = "channel", description = "Sets the birthday notification channel", requiredPermissions = Permission.MANAGE_SERVER)
public class ChannelSubCommand extends BatSubCommand { public class ChannelSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ChannelSubCommand(GuildService guildService) { public ChannelSubCommand(GuildService guildService) {
super("channel", "Sets the birthday notification channel", Permission.MANAGE_SERVER);
super.addOption(OptionType.CHANNEL, "channel", "The channel birthdays will be sent in", false); super.addOption(OptionType.CHANNEL, "channel", "The channel birthdays will be sent in", false);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.birthday.command; package cc.fascinated.bat.features.birthday.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -25,13 +26,13 @@ import java.util.Date;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("birthday:message.sub") @Component("birthday:message.sub")
@CommandInfo(name = "message", description = "Changes the message that is sent when it is a user's birthday", requiredPermissions = Permission.MANAGE_SERVER)
public class MessageSubCommand extends BatSubCommand { public class MessageSubCommand extends BatSubCommand {
private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("dd/MM/yyyy"); private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("dd/MM/yyyy");
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public MessageSubCommand(GuildService guildService) { public MessageSubCommand(GuildService guildService) {
super("message", "Changes the message that is sent when it is a user's birthday", Permission.MANAGE_SERVER);
super.addOption(OptionType.STRING, "message", "The message that is sent. (Placeholders: {user}, {age})", true); super.addOption(OptionType.STRING, "message", "The message that is sent. (Placeholders: {user}, {age})", true);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.birthday.command; package cc.fascinated.bat.features.birthday.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -18,12 +19,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("birthday:remove.sub") @Component("birthday:remove.sub")
@CommandInfo(name = "remove", description = "Remove your birthday from this guild")
public class RemoveSubCommand extends BatSubCommand { public class RemoveSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public RemoveSubCommand(GuildService guildService) { public RemoveSubCommand(GuildService guildService) {
super("remove", "Remove your birthday from this guild");
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.birthday.command; package cc.fascinated.bat.features.birthday.command;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.birthday.profile.BirthdayProfile; import cc.fascinated.bat.features.birthday.profile.BirthdayProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -24,13 +25,13 @@ import java.util.Date;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("birthday:add.sub") @Component("birthday:add.sub")
@CommandInfo(name = "set", description = "Add your birthday to this guild")
public class SetSubCommand extends BatSubCommand { public class SetSubCommand extends BatSubCommand {
private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("dd/MM/yyyy"); private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("dd/MM/yyyy");
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public SetSubCommand(GuildService guildService) { public SetSubCommand(GuildService guildService) {
super("set", "Add your birthday to this guild");
super.addOption(OptionType.STRING, "birthday", "Your birthday (format: DAY/MONTH/YEAR - 01/05/2004)", true); super.addOption(OptionType.STRING, "birthday", "Your birthday (format: DAY/MONTH/YEAR - 01/05/2004)", true);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.numberone; package cc.fascinated.bat.features.scoresaber.command.numberone;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TextChannelUtils; import cc.fascinated.bat.common.TextChannelUtils;
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile; import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
@ -22,12 +23,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-number-one-feed:channel.sub") @Component("scoresaber-number-one-feed:channel.sub")
@CommandInfo(name = "channel", description = "Sets the feed channel")
public class ChannelSubCommand extends BatSubCommand { public class ChannelSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ChannelSubCommand(GuildService guildService) { public ChannelSubCommand(GuildService guildService) {
super("channel", "Sets the feed channel");
super.addOption(OptionType.CHANNEL, "channel", "The channel scores are sent in", false); super.addOption(OptionType.CHANNEL, "channel", "The channel scores are sent in", false);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.numberone; package cc.fascinated.bat.features.scoresaber.command.numberone;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import lombok.NonNull; import lombok.NonNull;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -10,11 +11,10 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-number-one-feed") @Component("scoresaber-number-one-feed")
@CommandInfo(name = "scoresaber-number-one-feed", description = "Modifies the settings for the feed.", requiredPermissions = Permission.MANAGE_SERVER)
public class NumberOneFeedCommand extends BatCommand { public class NumberOneFeedCommand extends BatCommand {
public NumberOneFeedCommand(@NonNull ApplicationContext context) { public NumberOneFeedCommand(@NonNull ApplicationContext context) {
super("scoresaber-number-one-feed", "Modifies the settings for the feed.", true, Permission.MANAGE_SERVER); super.addSubCommand(context.getBean(ChannelSubCommand.class));
super.addSubCommand(context.getBean(ResetSubCommand.class));
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
super.addSubCommand("reset", context.getBean(ResetSubCommand.class));
} }
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.numberone; package cc.fascinated.bat.features.scoresaber.command.numberone;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile; import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,12 +18,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-number-one-feed:reset.sub") @Component("scoresaber-number-one-feed:reset.sub")
@CommandInfo(name = "reset", description = "Resets the settings")
public class ResetSubCommand extends BatSubCommand { public class ResetSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ResetSubCommand(GuildService guildService) { public ResetSubCommand(GuildService guildService) {
super("reset", "Resets the settings");
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.scoresaber; package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -21,13 +22,13 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber:link.sub") @Component("scoresaber:link.sub")
@CommandInfo(name = "link", description = "Links your ScoreSaber profile")
public class LinkSubCommand extends BatSubCommand { public class LinkSubCommand extends BatSubCommand {
private final ScoreSaberService scoreSaberService; private final ScoreSaberService scoreSaberService;
private final UserService userService; private final UserService userService;
@Autowired @Autowired
public LinkSubCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull UserService userService) { public LinkSubCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull UserService userService) {
super("link", "Links your ScoreSaber profile");
super.addOption(OptionType.STRING, "link", "Link your ScoreSaber profile", true); super.addOption(OptionType.STRING, "link", "Link your ScoreSaber profile", true);
this.scoreSaberService = scoreSaberService; this.scoreSaberService = scoreSaberService;
this.userService = userService; this.userService = userService;

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.scoresaber; package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.ScoreSaberService; import cc.fascinated.bat.service.ScoreSaberService;
@ -15,12 +16,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber:me.sub") @Component("scoresaber:me.sub")
@CommandInfo(name = "me", description = "Gets your ScoreSaber profile")
public class MeSubCommand extends BatSubCommand { public class MeSubCommand extends BatSubCommand {
private final ScoreSaberService scoreSaberService; private final ScoreSaberService scoreSaberService;
@Autowired @Autowired
public MeSubCommand(@NonNull ScoreSaberService scoreSaberService) { public MeSubCommand(@NonNull ScoreSaberService scoreSaberService) {
super("me", "Gets your ScoreSaber profile");
this.scoreSaberService = scoreSaberService; this.scoreSaberService = scoreSaberService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.scoresaber; package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,12 +18,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber:reset.sub") @Component("scoresaber:reset.sub")
@CommandInfo(name = "reset", description = "Reset your settings")
public class ResetSubCommand extends BatSubCommand { public class ResetSubCommand extends BatSubCommand {
private final UserService userService; private final UserService userService;
@Autowired @Autowired
public ResetSubCommand(@NonNull UserService userService) { public ResetSubCommand(@NonNull UserService userService) {
super("reset", "Reset your settings");
this.userService = userService; this.userService = userService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.scoresaber; package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.Colors; import cc.fascinated.bat.common.Colors;
import cc.fascinated.bat.common.DateUtils; import cc.fascinated.bat.common.DateUtils;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
@ -26,18 +27,18 @@ import java.time.LocalDateTime;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "scoresaber", description = "General ScoreSaber commands")
public class ScoreSaberCommand extends BatCommand { public class ScoreSaberCommand extends BatCommand {
private final ScoreSaberService scoreSaberService; private final ScoreSaberService scoreSaberService;
@Autowired @Autowired
public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull ApplicationContext context) { public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull ApplicationContext context) {
super("scoresaber", "General ScoreSaber commands");
this.scoreSaberService = scoreSaberService; this.scoreSaberService = scoreSaberService;
super.addSubCommand("link", context.getBean(LinkSubCommand.class)); super.addSubCommand(context.getBean(LinkSubCommand.class));
super.addSubCommand("user", context.getBean(UserSubCommand.class)); super.addSubCommand(context.getBean(UserSubCommand.class));
super.addSubCommand("me", context.getBean(MeSubCommand.class)); super.addSubCommand(context.getBean(MeSubCommand.class));
super.addSubCommand("reset", context.getBean(ResetSubCommand.class)); super.addSubCommand(context.getBean(ResetSubCommand.class));
} }
@Override @Override

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.scoresaber; package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.BatUser;
@ -19,13 +20,13 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber:user.sub") @Component("scoresaber:user.sub")
@CommandInfo(name = "user", description = "Gets a ScoreSaber profile")
public class UserSubCommand extends BatSubCommand { public class UserSubCommand extends BatSubCommand {
private final ScoreSaberService scoreSaberService; private final ScoreSaberService scoreSaberService;
private final UserService userService; private final UserService userService;
@Autowired @Autowired
public UserSubCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull UserService userService) { public UserSubCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull UserService userService) {
super("user", "Gets a ScoreSaber profile");
super.addOption(OptionType.USER, "user", "The user to view the ScoreSaber profile of", true); super.addOption(OptionType.USER, "user", "The user to view the ScoreSaber profile of", true);
this.scoreSaberService = scoreSaberService; this.scoreSaberService = scoreSaberService;
this.userService = userService; this.userService = userService;

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.userfeed; package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TextChannelUtils; import cc.fascinated.bat.common.TextChannelUtils;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
@ -22,12 +23,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-user-feed:channel.sub") @Component("scoresaber-user-feed:channel.sub")
@CommandInfo(name = "channel", description = "Sets the feed channel")
public class ChannelSubCommand extends BatSubCommand { public class ChannelSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ChannelSubCommand(GuildService guildService) { public ChannelSubCommand(GuildService guildService) {
super("channel", "Sets the feed channel");
super.addOption(OptionType.CHANNEL, "channel", "The channel scores are sent in", false); super.addOption(OptionType.CHANNEL, "channel", "The channel scores are sent in", false);
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.userfeed; package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatGuild;
@ -17,12 +18,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-user-feed:reset.sub") @Component("scoresaber-user-feed:reset.sub")
@CommandInfo(name = "reset", description = "Resets the settings")
public class ResetSubCommand extends BatSubCommand { public class ResetSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public ResetSubCommand(GuildService guildService) { public ResetSubCommand(GuildService guildService) {
super("reset", "Resets the settings");
this.guildService = guildService; this.guildService = guildService;
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.userfeed; package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import lombok.NonNull; import lombok.NonNull;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -10,12 +11,11 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-user-feed.command") @Component("scoresaber-user-feed.command")
@CommandInfo(name = "scoresaber-user-feed", description = "Modifies the settings for the feed.", requiredPermissions = Permission.MANAGE_SERVER)
public class UserFeedCommand extends BatCommand { public class UserFeedCommand extends BatCommand {
public UserFeedCommand(@NonNull ApplicationContext context) { public UserFeedCommand(@NonNull ApplicationContext context) {
super("scoresaber-user-feed", "Modifies the settings for the feed.", true, Permission.MANAGE_SERVER); super.addSubCommand(context.getBean(UserSubCommand.class));
super.addSubCommand(context.getBean(ChannelSubCommand.class));
super.addSubCommand("user", context.getBean(UserSubCommand.class)); super.addSubCommand(context.getBean(ResetSubCommand.class));
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
super.addSubCommand("reset", context.getBean(ResetSubCommand.class));
} }
} }

@ -1,6 +1,7 @@
package cc.fascinated.bat.features.scoresaber.command.userfeed; package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile; import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile; import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
@ -22,13 +23,13 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component("scoresaber-user-feed:user.sub") @Component("scoresaber-user-feed:user.sub")
@CommandInfo(name = "user", description = "Adds or removes a user from the feed")
public class UserSubCommand extends BatSubCommand { public class UserSubCommand extends BatSubCommand {
private final GuildService guildService; private final GuildService guildService;
private final UserService userService; private final UserService userService;
@Autowired @Autowired
public UserSubCommand(GuildService guildService, UserService userService) { public UserSubCommand(GuildService guildService, UserService userService) {
super("user", "Adds or removes a user from the feed");
super.addOption(OptionType.USER, "user", "Add or remove a user from the score feed", false); super.addOption(OptionType.USER, "user", "Add or remove a user from the score feed", false);
this.guildService = guildService; this.guildService = guildService;
this.userService = userService; this.userService = userService;

@ -21,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
@ -61,11 +58,12 @@ public class CommandService extends ListenerAdapter {
* @param command The command to register * @param command The command to register
*/ */
public void registerCommand(@NonNull BatCommand command) { public void registerCommand(@NonNull BatCommand command) {
if (commands.get(command.getName().toLowerCase()) != null) { String commandName = command.getCommandInfo().name().toLowerCase();
if (commands.get(commandName) != null) {
return; return;
} }
log.info("Registered command \"{}\"", command.getName()); log.info("Registered command \"{}\"", command.getCommandInfo().name());
commands.put(command.getName().toLowerCase(), command); commands.put(commandName, command);
} }
/** /**
@ -132,14 +130,14 @@ public class CommandService extends ListenerAdapter {
// No args provided, use the main command executor // No args provided, use the main command executor
if (event.getInteraction().getSubcommandName() == null) { if (event.getInteraction().getSubcommandName() == null) {
executor = command; executor = command;
requiredPermissions.addAll(command.getRequiredPermissions()); requiredPermissions.addAll(Arrays.asList(command.getCommandInfo().requiredPermissions()));
} else { } else {
// Subcommand provided, use the subcommand executor // Subcommand provided, use the subcommand executor
for (Map.Entry<String, BatSubCommand> subCommand : command.getSubCommands().entrySet()) { for (Map.Entry<String, BatSubCommand> subCommand : command.getSubCommands().entrySet()) {
if (subCommand.getKey().equalsIgnoreCase(event.getInteraction().getSubcommandName())) { if (subCommand.getKey().equalsIgnoreCase(event.getInteraction().getSubcommandName())) {
executor = subCommand.getValue(); executor = subCommand.getValue();
requiredPermissions.addAll(subCommand.getValue().getRequiredPermissions()); requiredPermissions.addAll(Arrays.asList(subCommand.getValue().getCommandInfo().requiredPermissions()));
requiredPermissions.addAll(command.getRequiredPermissions()); // not sure if we'd want this, but it's here for now requiredPermissions.addAll(Arrays.asList(command.getCommandInfo().requiredPermissions())); // not sure if we'd want this, but it's here for now
break; break;
} }
} }