From 0eb28e4dbce79d6a7b85fea853074987f60b23de Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 25 Jun 2024 17:20:19 +0100 Subject: [PATCH] edit user feed messages --- .../fascinated/bat/features/autorole/AutoRoleFeature.java | 2 ++ .../fascinated/bat/features/autorole/AutoRoleListener.java | 3 ++- .../bat/features/autorole/command/AddSubCommand.java | 1 - .../scoresaber/command/numberone/NumberOneFeedCommand.java | 2 +- .../scoresaber/command/userfeed/ChannelSubCommand.java | 6 +++--- .../java/cc/fascinated/bat/service/CommandService.java | 5 +---- .../java/cc/fascinated/bat/service/FeatureService.java | 7 +++++++ 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java index 3d172cd..4255a99 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java @@ -6,10 +6,12 @@ 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 AutoRoleFeature extends Feature { @Autowired public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { diff --git a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java index 0d0484c..e6cc5a6 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java @@ -16,7 +16,8 @@ import java.util.List; /** * @author Fascinated (fascinated7) */ -@Component @Log4j2 +@Component +@Log4j2 public class AutoRoleListener implements EventListener { @Override public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) { diff --git a/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java b/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java index a013ed0..e765c4a 100644 --- a/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/autorole/command/AddSubCommand.java @@ -6,7 +6,6 @@ import cc.fascinated.bat.common.RoleUtils; import cc.fascinated.bat.features.autorole.profile.AutoRoleProfile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; -import cc.fascinated.bat.service.DiscordService; import cc.fascinated.bat.service.GuildService; import lombok.NonNull; import net.dv8tion.jda.api.entities.Member; diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/NumberOneFeedCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/NumberOneFeedCommand.java index 322d928..999ccb2 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/NumberOneFeedCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/NumberOneFeedCommand.java @@ -30,7 +30,7 @@ public class NumberOneFeedCommand extends BatCommand { .addOptions(new OptionData(OptionType.CHANNEL, "channel", "The channel scores are sent in", false)) ).setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER)) .addSubcommands(new SubcommandData("reset", "Resets the feed settings to default")) - .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER)) + .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER)) ); } } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java index 829cd17..3025e87 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ChannelSubCommand.java @@ -36,12 +36,12 @@ public class ChannelSubCommand extends BatSubCommand { if (option == null) { if (!TextChannelUtils.isValidChannel(profile.getChannelId())) { interaction.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("Please provide a channel to set the ScoreSaber feed channel to") + .setDescription("Please provide a channel to set the feed channel to") .build()).queue(); return; } interaction.replyEmbeds(EmbedUtils.genericEmbed() - .setDescription("The current ScoreSaber feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId()))) + .setDescription("The current feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId()))) .build()).queue(); return; } @@ -58,7 +58,7 @@ public class ChannelSubCommand extends BatSubCommand { guildService.saveGuild(guild); interaction.replyEmbeds(EmbedUtils.successEmbed() - .setDescription("Successfully set the ScoreSaber feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention())) + .setDescription("Successfully set the feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention())) .build()).queue(); } } diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index e4d6767..144fbc8 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -13,7 +13,6 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Service; @@ -42,12 +41,10 @@ public class CommandService extends ListenerAdapter { private final UserService userService; @Autowired - public CommandService(@NonNull GuildService guildService, @NonNull UserService userService, @NonNull ApplicationContext context) { + public CommandService(@NonNull GuildService guildService, @NonNull UserService userService) { this.guildService = guildService; this.userService = userService; DiscordService.JDA.addEventListener(this); - - context.getBeansOfType(BatCommand.class).values().forEach(this::registerCommand); } /** diff --git a/src/main/java/cc/fascinated/bat/service/FeatureService.java b/src/main/java/cc/fascinated/bat/service/FeatureService.java index 3d7c0db..2a82066 100644 --- a/src/main/java/cc/fascinated/bat/service/FeatureService.java +++ b/src/main/java/cc/fascinated/bat/service/FeatureService.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.service; +import cc.fascinated.bat.command.BatCommand; import cc.fascinated.bat.features.Feature; import lombok.Getter; import lombok.NonNull; @@ -31,6 +32,12 @@ public class FeatureService { features.add(context.getBean(feature.getClass())); }); + context.getBeansOfType(BatCommand.class) + .values() + .forEach((command) -> { + commandService.registerCommand(context.getBean(command.getClass())); + }); + commandService.registerSlashCommands(); // Register all slash commands } }