forked from Fascinated/Bat
clean up scoresaber feature
This commit is contained in:
@ -4,12 +4,12 @@ import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.LinkSubCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.MeSubCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.UserSubCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ScoreFeedChannelCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ScoreFeedClearUsersCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ScoreFeedUserCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ScoreSaberUserFeedCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ChannelSubCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.ClearUsersSubCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.UserSubCommand;
|
||||
import cc.fascinated.bat.model.guild.BatGuild;
|
||||
import cc.fascinated.bat.model.user.BatUser;
|
||||
import lombok.NonNull;
|
||||
@ -60,12 +60,13 @@ public class CommandService extends ListenerAdapter {
|
||||
// Global commands
|
||||
registerCommand(context.getBean(ScoreSaberCommand.class)
|
||||
.addSubCommand("link", context.getBean(LinkSubCommand.class))
|
||||
.addSubCommand("user", context.getBean(UserSubCommand.class))
|
||||
.addSubCommand("user", context.getBean(cc.fascinated.bat.features.scoresaber.command.scoresaber.UserSubCommand.class))
|
||||
.addSubCommand("me", context.getBean(MeSubCommand.class))
|
||||
);
|
||||
registerCommand(context.getBean(ScoreSaberUserFeedCommand.class)
|
||||
.addSubCommand("user", context.getBean(ScoreFeedUserCommand.class))
|
||||
.addSubCommand("channel", context.getBean(ScoreFeedChannelCommand.class))
|
||||
.addSubCommand("clear-users", context.getBean(ScoreFeedClearUsersCommand.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
|
||||
@ -106,13 +107,7 @@ public class CommandService extends ListenerAdapter {
|
||||
@Override
|
||||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||
Guild discordGuild = event.getGuild();
|
||||
if (discordGuild == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getUser().isBot()) {
|
||||
return;
|
||||
}
|
||||
if (event.getMember() == null) {
|
||||
if (discordGuild == null || event.getUser().isBot() || event.getMember() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,17 +119,18 @@ public class CommandService extends ListenerAdapter {
|
||||
|
||||
BatGuild guild = guildService.getGuild(discordGuild.getId());
|
||||
BatUser user = userService.getUser(event.getUser().getId());
|
||||
|
||||
// No args provided, use the main command executor
|
||||
try {
|
||||
// No args provided, use the main command executor
|
||||
if (event.getInteraction().getSubcommandName() == null) {
|
||||
command.execute(guild, user, event.getChannel().asTextChannel(), event.getMember(), event.getInteraction());
|
||||
} else {
|
||||
for (Map.Entry<String, BatSubCommand> subCommand : command.getSubCommands().entrySet()) {
|
||||
if (subCommand.getKey().equalsIgnoreCase(event.getInteraction().getSubcommandName())) {
|
||||
subCommand.getValue().execute(guild, user, event.getChannel().asTextChannel(), event.getMember(), event.getInteraction());
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Subcommand provided, use the subcommand executor
|
||||
for (Map.Entry<String, BatSubCommand> subCommand : command.getSubCommands().entrySet()) {
|
||||
if (subCommand.getKey().equalsIgnoreCase(event.getInteraction().getSubcommandName())) {
|
||||
subCommand.getValue().execute(guild, user, event.getChannel().asTextChannel(), event.getMember(), event.getInteraction());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cc.fascinated.bat.service;
|
||||
|
||||
import cc.fascinated.bat.event.EventListener;
|
||||
import cc.fascinated.bat.features.scoresaber.ScoreSaberScoreFeedListener;
|
||||
import cc.fascinated.bat.features.scoresaber.UserScoreFeedListener;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,7 +24,7 @@ public class EventService {
|
||||
@Autowired
|
||||
public EventService(@NonNull ApplicationContext context) {
|
||||
registerListeners(
|
||||
context.getBean(ScoreSaberScoreFeedListener.class)
|
||||
context.getBean(UserScoreFeedListener.class)
|
||||
);
|
||||
log.info("Registered {} listeners.", LISTENERS.size());
|
||||
}
|
||||
|
Reference in New Issue
Block a user