make the scoresaber main cmd show more data
This commit is contained in:
parent
0b176c3b2a
commit
82e241f6ac
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli()/1000), true)
|
||||
.setTimestamp(LocalDateTime.now())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -8,7 +8,6 @@ import java.util.Date;
|
||||
|
||||
@UtilityClass
|
||||
public class DateUtils {
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;
|
||||
|
||||
/**
|
||||
|
16
src/main/java/cc/fascinated/bat/common/NumberUtils.java
Normal file
16
src/main/java/cc/fascinated/bat/common/NumberUtils.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user