forked from Fascinated/Bat
cleanup how i add sub commands to the commands
This commit is contained in:
parent
39c3d471c7
commit
b37a30b0a3
@ -20,6 +20,7 @@ import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -32,11 +33,15 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
private final ScoreSaberService scoreSaberService;
|
private final ScoreSaberService scoreSaberService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService) {
|
public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull ApplicationContext context) {
|
||||||
super("scoresaber");
|
super("scoresaber");
|
||||||
super.setCategory(Category.BEAT_SABER);
|
super.setCategory(Category.BEAT_SABER);
|
||||||
this.scoreSaberService = scoreSaberService;
|
this.scoreSaberService = scoreSaberService;
|
||||||
|
|
||||||
|
super.addSubCommand("link", context.getBean(LinkSubCommand.class));
|
||||||
|
super.addSubCommand("user", context.getBean(UserSubCommand.class));
|
||||||
|
super.addSubCommand("me", context.getBean(MeSubCommand.class));
|
||||||
|
|
||||||
super.setDescription("General ScoreSaber commands");
|
super.setDescription("General ScoreSaber commands");
|
||||||
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
|
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
|
||||||
.addSubcommands(new SubcommandData("link", "Link your ScoreSaber profile")
|
.addSubcommands(new SubcommandData("link", "Link your ScoreSaber profile")
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
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 lombok.NonNull;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,10 +16,14 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component("scoresaber-userfeed:feed.sub")
|
@Component("scoresaber-userfeed:feed.sub")
|
||||||
public class UserFeedCommand extends BatCommand {
|
public class UserFeedCommand extends BatCommand {
|
||||||
public UserFeedCommand() {
|
public UserFeedCommand(@NonNull ApplicationContext context) {
|
||||||
super("scoresaber-userfeed");
|
super("scoresaber-userfeed");
|
||||||
super.setCategory(Category.BEAT_SABER);
|
super.setCategory(Category.BEAT_SABER);
|
||||||
|
|
||||||
|
super.addSubCommand("user", context.getBean(UserSubCommand.class));
|
||||||
|
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
|
||||||
|
super.addSubCommand("clear-users", context.getBean(ClearUsersSubCommand.class));
|
||||||
|
|
||||||
super.setDescription("ScoreSaber user score feed commands");
|
super.setDescription("ScoreSaber user score feed commands");
|
||||||
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
|
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
|
||||||
.addSubcommands(new SubcommandData("user", "Edit your ScoreSaber score feed settings")
|
.addSubcommands(new SubcommandData("user", "Edit your ScoreSaber score feed settings")
|
||||||
|
@ -55,19 +55,10 @@ public class CommandService extends ListenerAdapter {
|
|||||||
DiscordService.JDA.addEventListener(this);
|
DiscordService.JDA.addEventListener(this);
|
||||||
|
|
||||||
// Guild commands
|
// Guild commands
|
||||||
// todo: add some, duh
|
registerCommand(context.getBean(UserFeedCommand.class));
|
||||||
|
|
||||||
// Global commands
|
// Global commands
|
||||||
registerCommand(context.getBean(ScoreSaberCommand.class)
|
registerCommand(context.getBean(ScoreSaberCommand.class));
|
||||||
.addSubCommand("link", context.getBean(LinkSubCommand.class))
|
|
||||||
.addSubCommand("user", context.getBean(cc.fascinated.bat.features.scoresaber.command.scoresaber.UserSubCommand.class))
|
|
||||||
.addSubCommand("me", context.getBean(MeSubCommand.class))
|
|
||||||
);
|
|
||||||
registerCommand(context.getBean(UserFeedCommand.class)
|
|
||||||
.addSubCommand("user", context.getBean(UserSubCommand.class))
|
|
||||||
.addSubCommand("channel", context.getBean(ChannelSubCommand.class))
|
|
||||||
.addSubCommand("clear-users", context.getBean(ClearUsersSubCommand.class))
|
|
||||||
);
|
|
||||||
|
|
||||||
registerSlashCommands(); // Register all slash commands
|
registerSlashCommands(); // Register all slash commands
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user