diff --git a/src/main/java/cc/fascinated/bat/command/BatCommand.java b/src/main/java/cc/fascinated/bat/command/BatCommand.java index d58fc62..4d762a3 100644 --- a/src/main/java/cc/fascinated/bat/command/BatCommand.java +++ b/src/main/java/cc/fascinated/bat/command/BatCommand.java @@ -4,7 +4,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.Setter; -import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; import net.dv8tion.jda.internal.interactions.CommandDataImpl; @@ -31,7 +30,7 @@ public abstract class BatCommand implements BatCommandExecutor { /** * The category of the command */ - private final Category category; + private Category category; /** * The command data for the slash command @@ -76,10 +75,11 @@ public abstract class BatCommand implements BatCommandExecutor { * The category of the command */ @AllArgsConstructor @Getter - private enum Category { + protected enum Category { GENERAL("General"), MODERATION("Moderation"), - SERVER("Server"); + SERVER("Server"), + BEAT_SABER("Beat Saber"); /** * The name of the category diff --git a/src/main/java/cc/fascinated/bat/command/BatCommandExecutor.java b/src/main/java/cc/fascinated/bat/command/BatCommandExecutor.java index e0202e8..1136d7c 100644 --- a/src/main/java/cc/fascinated/bat/command/BatCommandExecutor.java +++ b/src/main/java/cc/fascinated/bat/command/BatCommandExecutor.java @@ -2,8 +2,6 @@ package cc.fascinated.bat.command; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.user.BatUser; -import cc.fascinated.bat.service.GuildService; -import cc.fascinated.bat.service.UserService; import lombok.NonNull; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; diff --git a/src/main/java/cc/fascinated/bat/command/BatSubCommand.java b/src/main/java/cc/fascinated/bat/command/BatSubCommand.java index 12d8002..19d4848 100644 --- a/src/main/java/cc/fascinated/bat/command/BatSubCommand.java +++ b/src/main/java/cc/fascinated/bat/command/BatSubCommand.java @@ -1,15 +1,7 @@ package cc.fascinated.bat.command; -import cc.fascinated.bat.model.BatGuild; -import cc.fascinated.bat.model.user.BatUser; -import cc.fascinated.bat.service.GuildService; -import cc.fascinated.bat.service.UserService; import lombok.AllArgsConstructor; import lombok.Getter; -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; /** * @author Fascinated (fascinated7) diff --git a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/LinkSubCommand.java b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/LinkSubCommand.java index bf356ff..5bfdee8 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/LinkSubCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/LinkSubCommand.java @@ -1,7 +1,6 @@ package cc.fascinated.bat.command.impl.global.beatsaber.scoresaber; import cc.fascinated.bat.command.BatSubCommand; -import cc.fascinated.bat.common.Profile; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.beatsaber.scoresaber.ScoreSaberAccountToken; import cc.fascinated.bat.model.user.BatUser; @@ -16,8 +15,6 @@ import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Map; - /** * @author Fascinated (fascinated7) */ diff --git a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/ScoreSaberCommand.java b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/ScoreSaberCommand.java index d2beedc..0545d64 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/ScoreSaberCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/ScoreSaberCommand.java @@ -1,13 +1,13 @@ package cc.fascinated.bat.command.impl.global.beatsaber.scoresaber; import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.common.DateUtils; +import cc.fascinated.bat.common.NumberUtils; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.beatsaber.scoresaber.ScoreSaberAccountToken; import cc.fascinated.bat.model.user.BatUser; import cc.fascinated.bat.model.user.profiles.ScoreSaberProfile; -import cc.fascinated.bat.service.GuildService; import cc.fascinated.bat.service.ScoreSaberService; -import cc.fascinated.bat.service.UserService; import lombok.NonNull; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.Member; @@ -21,6 +21,8 @@ import net.dv8tion.jda.internal.interactions.CommandDataImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; + /** * @author Fascinated (fascinated7) */ @@ -31,6 +33,7 @@ public class ScoreSaberCommand extends BatCommand { @Autowired public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService) { super("scoresaber"); + super.setCategory(Category.BEAT_SABER); this.scoreSaberService = scoreSaberService; super.setDescription("View a user's ScoreSaber profile"); @@ -66,7 +69,15 @@ public class ScoreSaberCommand extends BatCommand { */ public static MessageEmbed buildProfileEmbed(ScoreSaberAccountToken account) { return new EmbedBuilder() + .setAuthor(account.getName() + "'s Profile", "https://scoresaber.com/u/%s".formatted(account.getId()), + "https://cdn.scoresaber.com/avatars/%s.jpg".formatted(account.getId())) .addField("Name", account.getName(), true) + .addField("Country", account.getCountry(), true) + .addField("Rank", "#" + account.getRank(), true) + .addField("Country Rank", "#" + account.getCountryRank(), true) + .addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true) + .addField("Joined", "".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli()/1000), true) + .setTimestamp(LocalDateTime.now()) .build(); } } diff --git a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/UserSubCommand.java b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/UserSubCommand.java index 00af7df..b597d21 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/UserSubCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/global/beatsaber/scoresaber/UserSubCommand.java @@ -3,8 +3,6 @@ package cc.fascinated.bat.command.impl.global.beatsaber.scoresaber; import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.user.BatUser; -import cc.fascinated.bat.service.GuildService; -import cc.fascinated.bat.service.UserService; import lombok.NonNull; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; diff --git a/src/main/java/cc/fascinated/bat/common/DateUtils.java b/src/main/java/cc/fascinated/bat/common/DateUtils.java index 2b01724..4ab4a17 100644 --- a/src/main/java/cc/fascinated/bat/common/DateUtils.java +++ b/src/main/java/cc/fascinated/bat/common/DateUtils.java @@ -8,7 +8,6 @@ import java.util.Date; @UtilityClass public class DateUtils { - private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT; /** diff --git a/src/main/java/cc/fascinated/bat/common/NumberUtils.java b/src/main/java/cc/fascinated/bat/common/NumberUtils.java new file mode 100644 index 0000000..075483d --- /dev/null +++ b/src/main/java/cc/fascinated/bat/common/NumberUtils.java @@ -0,0 +1,16 @@ +package cc.fascinated.bat.common; + +/** + * @author Fascinated (fascinated7) + */ +public class NumberUtils { + /** + * Formats a number with commas. + * + * @param number the number to format + * @return the formatted number + */ + public static String formatNumberCommas(double number) { + return String.format("%,.0f", number); + } +} diff --git a/src/main/java/cc/fascinated/bat/config/MongoConfig.java b/src/main/java/cc/fascinated/bat/config/MongoConfig.java index 14cb512..d9f7d5c 100644 --- a/src/main/java/cc/fascinated/bat/config/MongoConfig.java +++ b/src/main/java/cc/fascinated/bat/config/MongoConfig.java @@ -6,16 +6,7 @@ import org.springframework.data.mongodb.MongoDatabaseFactory; import org.springframework.data.mongodb.core.convert.DbRefResolver; import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; -import org.springframework.data.mongodb.core.convert.MongoCustomConversions; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; -import org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback; -import org.springframework.data.mongodb.core.mapping.event.MongoMappingEvent; -import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; /** * @author Fascinated (fascinated7)