diff --git a/pom.xml b/pom.xml
index afe8af3..caf12f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,6 +85,10 @@
org.springframework.boot
spring-boot-starter-websocket
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
diff --git a/src/main/java/cc/fascinated/bat/BatApplication.java b/src/main/java/cc/fascinated/bat/BatApplication.java
index a5ca114..b7c2ac5 100644
--- a/src/main/java/cc/fascinated/bat/BatApplication.java
+++ b/src/main/java/cc/fascinated/bat/BatApplication.java
@@ -7,12 +7,14 @@ import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Objects;
+@EnableCaching
@SpringBootApplication()
@Log4j2(topic = "Ember")
public class BatApplication {
diff --git a/src/main/java/cc/fascinated/bat/common/Profile.java b/src/main/java/cc/fascinated/bat/common/Profile.java
index 56974c7..2527886 100644
--- a/src/main/java/cc/fascinated/bat/common/Profile.java
+++ b/src/main/java/cc/fascinated/bat/common/Profile.java
@@ -3,7 +3,6 @@ package cc.fascinated.bat.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
-import org.springframework.data.annotation.Transient;
/**
* @author Fascinated (fascinated7)
diff --git a/src/main/java/cc/fascinated/bat/features/Feature.java b/src/main/java/cc/fascinated/bat/features/Feature.java
new file mode 100644
index 0000000..8d34f24
--- /dev/null
+++ b/src/main/java/cc/fascinated/bat/features/Feature.java
@@ -0,0 +1,23 @@
+package cc.fascinated.bat.features;
+
+import cc.fascinated.bat.service.CommandService;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Fascinated (fascinated7)
+ */
+@RequiredArgsConstructor
+@Getter
+@Component
+public abstract class Feature {
+ @Autowired
+ private CommandService commandService;
+
+ /**
+ * The name of the feature
+ */
+ private final String name;
+}
diff --git a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java
new file mode 100644
index 0000000..3d172cd
--- /dev/null
+++ b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleFeature.java
@@ -0,0 +1,20 @@
+package cc.fascinated.bat.features.autorole;
+
+import cc.fascinated.bat.features.Feature;
+import cc.fascinated.bat.features.autorole.command.AutoRoleCommand;
+import cc.fascinated.bat.service.CommandService;
+import lombok.NonNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @author Fascinated (fascinated7)
+ */
+public class AutoRoleFeature extends Feature {
+ @Autowired
+ public AutoRoleFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
+ super("AutoRole");
+
+ commandService.registerCommand(context.getBean(AutoRoleCommand.class));
+ }
+}
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 b80ec72..0d0484c 100644
--- a/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java
+++ b/src/main/java/cc/fascinated/bat/features/autorole/AutoRoleListener.java
@@ -18,7 +18,6 @@ import java.util.List;
*/
@Component @Log4j2
public class AutoRoleListener implements EventListener {
-
@Override
public void onGuildMemberJoin(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberJoinEvent event) {
AutoRoleProfile profile = guild.getProfile(AutoRoleProfile.class);
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java b/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java
index cd7632a..a150cc2 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/NumberOneScoreFeedListener.java
@@ -1,6 +1,9 @@
package cc.fascinated.bat.features.scoresaber;
-import cc.fascinated.bat.common.*;
+import cc.fascinated.bat.common.DateUtils;
+import cc.fascinated.bat.common.EmbedUtils;
+import cc.fascinated.bat.common.NumberUtils;
+import cc.fascinated.bat.common.ScoreSaberUtils;
import cc.fascinated.bat.event.EventListener;
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
import cc.fascinated.bat.model.BatGuild;
@@ -38,6 +41,11 @@ public class NumberOneScoreFeedListener implements EventListener {
if (!leaderboard.isRanked()) { // Only send if the leaderboard is ranked
return;
}
+ log.info("A new #1 score has been set by {} on {} ({})!",
+ player.getName(),
+ leaderboard.getSongName(),
+ "%s⭐".formatted(NumberUtils.formatNumberCommas(leaderboard.getStars()))
+ );
for (Guild guild : DiscordService.JDA.getGuilds()) {
BatGuild batGuild = guildService.getGuild(guild.getId());
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java b/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java
new file mode 100644
index 0000000..d005c55
--- /dev/null
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/ScoreSaberFeature.java
@@ -0,0 +1,27 @@
+package cc.fascinated.bat.features.scoresaber;
+
+import cc.fascinated.bat.features.Feature;
+import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
+import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
+import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
+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 ScoreSaberFeature extends Feature {
+
+ @Autowired
+ public ScoreSaberFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
+ super("ScoreSaber");
+
+ commandService.registerCommand(context.getBean(ScoreSaberCommand.class));
+ commandService.registerCommand(context.getBean(UserFeedCommand.class));
+ commandService.registerCommand(context.getBean(NumberOneFeedCommand.class));
+ }
+}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java b/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java
index 46d8ed8..738ded1 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/UserScoreFeedListener.java
@@ -1,12 +1,15 @@
package cc.fascinated.bat.features.scoresaber;
-import cc.fascinated.bat.common.*;
+import cc.fascinated.bat.common.DateUtils;
+import cc.fascinated.bat.common.EmbedUtils;
+import cc.fascinated.bat.common.NumberUtils;
+import cc.fascinated.bat.common.ScoreSaberUtils;
import cc.fascinated.bat.event.EventListener;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
+import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardToken;
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberPlayerScoreToken;
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberScoreToken;
-import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.service.DiscordService;
import cc.fascinated.bat.service.GuildService;
import lombok.extern.log4j.Log4j2;
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java
index 12e4aea..2dca61c 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ChannelSubCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/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 #1 feed channel to")
+ .setDescription("Please provide a channel to set the feed channel to")
.build()).queue();
return;
}
interaction.replyEmbeds(EmbedUtils.errorEmbed()
- .setDescription("The current ScoreSaber #1 feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId())))
+ .setDescription("The current feed channel is %s".formatted(TextChannelUtils.getChannelMention(profile.getChannelId())))
.build()).queue();
return;
}
@@ -57,8 +57,8 @@ public class ChannelSubCommand extends BatSubCommand {
profile.setChannelId(targetChannel.getId());
guildService.saveGuild(guild);
- interaction.replyEmbeds(EmbedUtils.errorEmbed()
- .setDescription("Successfully set the ScoreSaber #1 feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention()))
+ interaction.replyEmbeds(EmbedUtils.successEmbed()
+ .setDescription("Successfully set the feed channel to %s".formatted(targetChannel.asTextChannel().getAsMention()))
.build()).queue();
}
}
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 3e4e066..322d928 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
@@ -21,15 +21,15 @@ public class NumberOneFeedCommand extends BatCommand {
super.setCategory(Category.BEAT_SABER);
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
- super.addSubCommand("clear-channel", context.getBean(ClearChannelSubCommand.class));
+ super.addSubCommand("reset", context.getBean(ResetSubCommand.class));
- super.setDescription("ScoreSaber #1 score feed commands");
+ super.setDescription("Modifies the settings for the feed.");
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
.setGuildOnly(true)
- .addSubcommands(new SubcommandData("channel", "Edit the channel the score feed is sent in")
- .addOptions(new OptionData(OptionType.CHANNEL, "channel", "Set the channel to send the score feed in", false))
+ .addSubcommands(new SubcommandData("channel", "Change the channel the score feed is sent in")
+ .addOptions(new OptionData(OptionType.CHANNEL, "channel", "The channel scores are sent in", false))
).setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
- .addSubcommands(new SubcommandData("clear-channel", "Disable the score feed"))
+ .addSubcommands(new SubcommandData("reset", "Resets the feed settings to default"))
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
);
}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ClearChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java
similarity index 79%
rename from src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ClearChannelSubCommand.java
rename to src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java
index d8fdf71..9721d31 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ClearChannelSubCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/numberone/ResetSubCommand.java
@@ -16,12 +16,12 @@ import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
-@Component("scoresaber-number-one-feed:clear-channel.sub")
-public class ClearChannelSubCommand extends BatSubCommand {
+@Component("scoresaber-number-one-feed:reset.sub")
+public class ResetSubCommand extends BatSubCommand {
private final GuildService guildService;
@Autowired
- public ClearChannelSubCommand(GuildService guildService) {
+ public ResetSubCommand(GuildService guildService) {
this.guildService = guildService;
}
@@ -31,8 +31,8 @@ public class ClearChannelSubCommand extends BatSubCommand {
profile.setChannelId(null);
guildService.saveGuild(guild);
- interaction.replyEmbeds(EmbedUtils.errorEmbed()
- .setDescription("Successfully cleared the ScoreSaber #1 feed channel")
+ interaction.replyEmbeds(EmbedUtils.successEmbed()
+ .setDescription("Successfully reset the settings.")
.build()).queue();
}
}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java
index 128c99c..575ca6b 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/LinkSubCommand.java
@@ -2,10 +2,10 @@ package cc.fascinated.bat.features.scoresaber.command.scoresaber;
import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.common.EmbedUtils;
-import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
+import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
-import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
+import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
import cc.fascinated.bat.service.ScoreSaberService;
import cc.fascinated.bat.service.UserService;
import lombok.NonNull;
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java
index cd9263c..82f3085 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java
@@ -5,10 +5,10 @@ import cc.fascinated.bat.common.Colors;
import cc.fascinated.bat.common.DateUtils;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.NumberUtils;
-import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
+import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
-import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
+import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
import cc.fascinated.bat.service.ScoreSaberService;
import lombok.NonNull;
import net.dv8tion.jda.api.EmbedBuilder;
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 fd07eb8..e6c862e 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
@@ -3,8 +3,8 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.common.EmbedUtils;
import cc.fascinated.bat.common.TextChannelUtils;
-import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
+import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.GuildService;
import lombok.NonNull;
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
-@Component("scoresaber-userfeed:channel.sub")
+@Component("scoresaber-user-feed:channel.sub")
public class ChannelSubCommand extends BatSubCommand {
private final GuildService guildService;
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearChannelSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearChannelSubCommand.java
deleted file mode 100644
index 343c513..0000000
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearChannelSubCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cc.fascinated.bat.features.scoresaber.command.userfeed;
-
-import cc.fascinated.bat.command.BatSubCommand;
-import cc.fascinated.bat.common.EmbedUtils;
-import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
-import cc.fascinated.bat.model.BatGuild;
-import cc.fascinated.bat.model.BatUser;
-import cc.fascinated.bat.service.GuildService;
-import lombok.NonNull;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
-import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author Fascinated (fascinated7)
- */
-@Component("scoresaber-userfeed:clear-channel.sub")
-public class ClearChannelSubCommand extends BatSubCommand {
- private final GuildService guildService;
-
- @Autowired
- public ClearChannelSubCommand(GuildService guildService) {
- this.guildService = guildService;
- }
-
- @Override
- public void execute(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull TextChannel channel, @NonNull Member member, @NonNull SlashCommandInteraction interaction) {
- GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class);
- profile.setChannelId(null);
- guildService.saveGuild(guild);
-
- interaction.replyEmbeds(EmbedUtils.errorEmbed()
- .setDescription("Successfully cleared the ScoreSaber feed channel")
- .build()).queue();
- }
-}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearUsersSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java
similarity index 83%
rename from src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearUsersSubCommand.java
rename to src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java
index ae453e7..4eca46e 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ClearUsersSubCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/ResetSubCommand.java
@@ -2,8 +2,8 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.common.EmbedUtils;
-import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
+import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.GuildService;
import lombok.NonNull;
@@ -16,23 +16,24 @@ import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
-@Component("scoresaber-userfeed:clearusers.sub")
-public class ClearUsersSubCommand extends BatSubCommand {
+@Component("scoresaber-user-feed:reset.sub")
+public class ResetSubCommand extends BatSubCommand {
private final GuildService guildService;
@Autowired
- public ClearUsersSubCommand(GuildService guildService) {
+ public ResetSubCommand(GuildService guildService) {
this.guildService = guildService;
}
@Override
public void execute(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull TextChannel channel, @NonNull Member member, @NonNull SlashCommandInteraction interaction) {
GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class);
+ profile.setChannelId(null);
profile.getTrackedUsers().clear();
guildService.saveGuild(guild);
interaction.replyEmbeds(EmbedUtils.successEmbed()
- .setDescription("Successfully cleared all users from the ScoreSaber feed")
+ .setDescription("Successfully reset the settings.")
.build()).queue();
}
}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserFeedCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserFeedCommand.java
index d02d67f..6411bbd 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserFeedCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserFeedCommand.java
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
-@Component("scoresaber-userfeed.command")
+@Component("scoresaber-user-feed.command")
public class UserFeedCommand extends BatCommand {
public UserFeedCommand(@NonNull ApplicationContext context) {
super("scoresaber-user-feed");
@@ -22,24 +22,20 @@ public class UserFeedCommand extends BatCommand {
super.addSubCommand("user", context.getBean(UserSubCommand.class));
super.addSubCommand("channel", context.getBean(ChannelSubCommand.class));
- super.addSubCommand("clear-channel", context.getBean(ClearChannelSubCommand.class));
- super.addSubCommand("clear-users", context.getBean(ClearUsersSubCommand.class));
+ super.addSubCommand("reset", context.getBean(ResetSubCommand.class));
- super.setDescription("ScoreSaber user score feed commands");
+ super.setDescription("Modifies the settings for the feed.");
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription())
.setGuildOnly(true)
.addSubcommands(new SubcommandData("user", "Edit the users in the score feed")
.addOptions(new OptionData(OptionType.USER, "user", "Add or remove a user from the score feed", false))
).setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
- .addSubcommands(new SubcommandData("clear-users", "Remove all users from the score feed"))
- .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
-
- .addSubcommands(new SubcommandData("channel", "Edit the channel the score feed is sent in")
- .addOptions(new OptionData(OptionType.CHANNEL, "channel", "Set the channel to send the score feed in", false))
+ .addSubcommands(new SubcommandData("channel", "Change the channel the score feed is sent in")
+ .addOptions(new OptionData(OptionType.CHANNEL, "channel", "The channel scores are sent in", false))
).setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
- .addSubcommands(new SubcommandData("clear-channel", "Disable the score feed"))
+ .addSubcommands(new SubcommandData("reset", "Resets the feed settings to default"))
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER))
);
}
diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java
index a48bbfb..122af70 100644
--- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java
+++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/userfeed/UserSubCommand.java
@@ -2,10 +2,10 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed;
import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.common.EmbedUtils;
-import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
-import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
+import cc.fascinated.bat.model.BatGuild;
+import cc.fascinated.bat.model.BatUser;
import cc.fascinated.bat.service.GuildService;
import cc.fascinated.bat.service.UserService;
import lombok.NonNull;
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
-@Component("scoresaber-userfeed:user.sub")
+@Component("scoresaber-user-feed:user.sub")
public class UserSubCommand extends BatSubCommand {
private final GuildService guildService;
private final UserService userService;
@@ -38,7 +38,7 @@ public class UserSubCommand extends BatSubCommand {
if (option == null){
if (profile.getTrackedUsers().isEmpty()) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
- .setDescription("There are no users being tracked in the ScoreSaber feed")
+ .setDescription("There are no users being tracked in the feed")
.build()).queue();
return;
}
@@ -50,7 +50,7 @@ public class UserSubCommand extends BatSubCommand {
));
}
interaction.replyEmbeds(EmbedUtils.genericEmbed()
- .setDescription("The current users being tracked in the ScoreSaber feed are:\n%s".formatted(stringBuilder.toString()))
+ .setDescription("The current users being tracked in the feed are:\n%s".formatted(stringBuilder.toString()))
.build()).queue();
return;
}
@@ -68,12 +68,12 @@ public class UserSubCommand extends BatSubCommand {
if (profile.getTrackedUsers().contains(targetProfile.getSteamId())) {
profile.getTrackedUsers().remove(targetProfile.getSteamId());
interaction.replyEmbeds(EmbedUtils.successEmbed()
- .setDescription("Successfully removed %s from the ScoreSaber feed".formatted(target.getAsMention()))
+ .setDescription("Successfully removed %s from the feed".formatted(target.getAsMention()))
.build()).queue();
} else {
profile.getTrackedUsers().add(targetProfile.getSteamId());
interaction.replyEmbeds(EmbedUtils.successEmbed()
- .setDescription("Successfully added %s to the ScoreSaber feed".formatted(target.getAsMention()))
+ .setDescription("Successfully added %s to the feed".formatted(target.getAsMention()))
.build()).queue();
}
guildService.saveGuild(guild);
diff --git a/src/main/java/cc/fascinated/bat/model/BatGuild.java b/src/main/java/cc/fascinated/bat/model/BatGuild.java
index c284663..039b52e 100644
--- a/src/main/java/cc/fascinated/bat/model/BatGuild.java
+++ b/src/main/java/cc/fascinated/bat/model/BatGuild.java
@@ -1,6 +1,5 @@
package cc.fascinated.bat.model;
-import cc.fascinated.bat.common.Profile;
import cc.fascinated.bat.common.ProfileHolder;
import cc.fascinated.bat.service.DiscordService;
import lombok.Getter;
@@ -11,8 +10,7 @@ import net.dv8tion.jda.api.entities.Guild;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Date;
/**
* @author Fascinated (fascinated7)
@@ -27,6 +25,11 @@ public class BatGuild extends ProfileHolder {
*/
@NonNull @Id private final String id;
+ /**
+ * The time this guild was joined
+ */
+ private Date createdAt = new Date();
+
/**
* Gets the guild as the JDA Guild
*
diff --git a/src/main/java/cc/fascinated/bat/model/BatUser.java b/src/main/java/cc/fascinated/bat/model/BatUser.java
index b142f95..ffec7b6 100644
--- a/src/main/java/cc/fascinated/bat/model/BatUser.java
+++ b/src/main/java/cc/fascinated/bat/model/BatUser.java
@@ -1,6 +1,5 @@
package cc.fascinated.bat.model;
-import cc.fascinated.bat.common.Profile;
import cc.fascinated.bat.common.ProfileHolder;
import cc.fascinated.bat.service.DiscordService;
import lombok.Getter;
@@ -11,8 +10,7 @@ import net.dv8tion.jda.api.entities.User;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Date;
/**
* @author Fascinated (fascinated7)
@@ -27,6 +25,11 @@ public class BatUser extends ProfileHolder {
*/
@NonNull @Id private final String id;
+ /**
+ * The time this user was created
+ */
+ private Date createdAt = new Date();
+
/**
* Gets the guild as the JDA Guild
*
diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java
index 54d8bc9..e4d6767 100644
--- a/src/main/java/cc/fascinated/bat/service/CommandService.java
+++ b/src/main/java/cc/fascinated/bat/service/CommandService.java
@@ -2,12 +2,7 @@ package cc.fascinated.bat.service;
import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.BatSubCommand;
-import cc.fascinated.bat.command.impl.PingCommand;
import cc.fascinated.bat.common.EmbedUtils;
-import cc.fascinated.bat.features.autorole.command.AutoRoleCommand;
-import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
-import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
-import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
import cc.fascinated.bat.model.BatGuild;
import cc.fascinated.bat.model.BatUser;
import lombok.NonNull;
@@ -52,18 +47,7 @@ public class CommandService extends ListenerAdapter {
this.userService = userService;
DiscordService.JDA.addEventListener(this);
- // todo: auto register commands
-
- // Guild commands
- registerCommand(context.getBean(UserFeedCommand.class));
- registerCommand(context.getBean(NumberOneFeedCommand.class));
- registerCommand(context.getBean(AutoRoleCommand.class));
-
- // Global commands
- registerCommand(context.getBean(ScoreSaberCommand.class));
- registerCommand(context.getBean(PingCommand.class));
-
- registerSlashCommands(); // Register all slash commands
+ context.getBeansOfType(BatCommand.class).values().forEach(this::registerCommand);
}
/**
@@ -72,6 +56,10 @@ public class CommandService extends ListenerAdapter {
* @param command The command to register
*/
public void registerCommand(@NonNull BatCommand command) {
+ if (commands.get(command.getName().toLowerCase()) != null) {
+ return;
+ }
+ log.info("Registered command \"{}\"", command.getName());
commands.put(command.getName().toLowerCase(), command);
}
diff --git a/src/main/java/cc/fascinated/bat/service/EventService.java b/src/main/java/cc/fascinated/bat/service/EventService.java
index d9965a2..5ef629b 100644
--- a/src/main/java/cc/fascinated/bat/service/EventService.java
+++ b/src/main/java/cc/fascinated/bat/service/EventService.java
@@ -9,7 +9,6 @@ import cc.fascinated.bat.model.BatUser;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
-import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/cc/fascinated/bat/service/FeatureService.java b/src/main/java/cc/fascinated/bat/service/FeatureService.java
new file mode 100644
index 0000000..3d7c0db
--- /dev/null
+++ b/src/main/java/cc/fascinated/bat/service/FeatureService.java
@@ -0,0 +1,36 @@
+package cc.fascinated.bat.service;
+
+import cc.fascinated.bat.features.Feature;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.DependsOn;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Fascinated (fascinated7)
+ */
+@Service @Getter @Log4j2
+@DependsOn("commandService")
+public class FeatureService {
+ /**
+ * The registered features
+ */
+ private final List features = new ArrayList<>();
+
+ @Autowired
+ public FeatureService(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
+ context.getBeansOfType(Feature.class)
+ .values()
+ .forEach((feature) -> {
+ features.add(context.getBean(feature.getClass()));
+ });
+
+ commandService.registerSlashCommands(); // Register all slash commands
+ }
+}