forked from Fascinated/Bat
cleanup
This commit is contained in:
parent
06a2584e63
commit
91ecc9882c
@ -2,7 +2,7 @@ package cc.fascinated.bat.features.scoresaber;
|
|||||||
|
|
||||||
import cc.fascinated.bat.common.NumberUtils;
|
import cc.fascinated.bat.common.NumberUtils;
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardToken;
|
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.ScoreSaberPlayerScoreToken;
|
||||||
@ -49,12 +49,12 @@ public class NumberOneScoreFeedListener implements EventListener {
|
|||||||
if (batGuild == null) {
|
if (batGuild == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GuildNumberOneScoreFeedProfile profile = batGuild.getProfile(GuildNumberOneScoreFeedProfile.class);
|
NumberOneScoreFeedProfile profile = batGuild.getProfile(NumberOneScoreFeedProfile.class);
|
||||||
if (profile == null || profile.getChannelId() == null) {
|
if (profile == null || profile.getChannelId() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextChannel channel = profile.getAsTextChannel();
|
TextChannel channel = profile.getTextChannel();
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId());
|
log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId());
|
||||||
profile.setChannelId(null);
|
profile.setChannelId(null);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cc.fascinated.bat.features.scoresaber;
|
package cc.fascinated.bat.features.scoresaber;
|
||||||
|
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberLeaderboardToken;
|
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.ScoreSaberPlayerScoreToken;
|
||||||
@ -36,12 +36,12 @@ public class UserScoreFeedListener implements EventListener {
|
|||||||
if (batGuild == null) {
|
if (batGuild == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GuildUserScoreFeedProfile profile = batGuild.getProfile(GuildUserScoreFeedProfile.class);
|
UserScoreFeedProfile profile = batGuild.getProfile(UserScoreFeedProfile.class);
|
||||||
if (profile == null || profile.getChannelId() == null || !profile.getTrackedUsers().contains(player.getId())) {
|
if (profile == null || profile.getChannelId() == null || !profile.getTrackedUsers().contains(player.getId())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextChannel channel = profile.getAsTextChannel();
|
TextChannel channel = profile.getTextChannel();
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId());
|
log.error("Scoresaber user feed channel is null for guild {}, removing the stored channel.", guild.getId());
|
||||||
profile.setChannelId(null);
|
profile.setChannelId(null);
|
||||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatSubCommand;
|
|||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.common.TextChannelUtils;
|
import cc.fascinated.bat.common.TextChannelUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
@ -35,7 +35,7 @@ public class ChannelSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
GuildNumberOneScoreFeedProfile profile = guild.getProfile(GuildNumberOneScoreFeedProfile.class);
|
NumberOneScoreFeedProfile profile = guild.getProfile(NumberOneScoreFeedProfile.class);
|
||||||
OptionMapping option = interaction.getOption("channel");
|
OptionMapping option = interaction.getOption("channel");
|
||||||
if (option == null) {
|
if (option == null) {
|
||||||
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
||||||
|
@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.numberone;
|
|||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildNumberOneScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.NumberOneScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
GuildNumberOneScoreFeedProfile profile = guild.getProfile(GuildNumberOneScoreFeedProfile.class);
|
NumberOneScoreFeedProfile profile = guild.getProfile(NumberOneScoreFeedProfile.class);
|
||||||
profile.reset();
|
profile.reset();
|
||||||
guildService.saveGuild(guild);
|
guildService.saveGuild(guild);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package cc.fascinated.bat.features.scoresaber.command.scoresaber;
|
|||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
|
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
|
||||||
@ -65,7 +64,7 @@ public class LinkSubCommand extends BatSubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getProfile(UserScoreSaberProfile.class).setSteamId(id);
|
user.getScoreSaberProfile().setAccountId(id);
|
||||||
userService.saveUser(user);
|
userService.saveUser(user);
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
||||||
.setDescription("Successfully linked your [ScoreSaber](%s) profile".formatted("https://scoresaber.com/u/%s".formatted(id)))
|
.setDescription("Successfully linked your [ScoreSaber](%s) profile".formatted("https://scoresaber.com/u/%s".formatted(id)))
|
||||||
|
@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.scoresaber;
|
|||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.UserService;
|
import cc.fascinated.bat.service.UserService;
|
||||||
@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
UserScoreSaberProfile profile = guild.getProfile(UserScoreSaberProfile.class);
|
ScoreSaberProfile profile = user.getScoreSaberProfile();
|
||||||
profile.reset();
|
profile.reset();
|
||||||
userService.saveUser(user);
|
userService.saveUser(user);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import cc.fascinated.bat.common.DateUtils;
|
|||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.common.NumberUtils;
|
import cc.fascinated.bat.common.NumberUtils;
|
||||||
import cc.fascinated.bat.exception.RateLimitException;
|
import cc.fascinated.bat.exception.RateLimitException;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
|
import cc.fascinated.bat.model.token.beatsaber.scoresaber.ScoreSaberAccountToken;
|
||||||
@ -49,8 +49,8 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
* @param interaction The interaction
|
* @param interaction The interaction
|
||||||
*/
|
*/
|
||||||
public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) {
|
public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) {
|
||||||
UserScoreSaberProfile profile = user.getProfile(UserScoreSaberProfile.class);
|
ScoreSaberProfile profile = user.getScoreSaberProfile();
|
||||||
if (profile.getSteamId() == null) {
|
if (profile.getAccountId() == null) {
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||||
.setDescription("%s does not have a linked ScoreSaber account".formatted(user.getDiscordUser().getAsMention()))
|
.setDescription("%s does not have a linked ScoreSaber account".formatted(user.getDiscordUser().getAsMention()))
|
||||||
@ -64,7 +64,7 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
long before = System.currentTimeMillis();
|
long before = System.currentTimeMillis();
|
||||||
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId());
|
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getAccountId());
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||||
|
@ -4,7 +4,7 @@ import cc.fascinated.bat.command.BatSubCommand;
|
|||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.common.TextChannelUtils;
|
import cc.fascinated.bat.common.TextChannelUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
@ -35,7 +35,7 @@ public class ChannelSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class);
|
UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class);
|
||||||
OptionMapping option = interaction.getOption("channel");
|
OptionMapping option = interaction.getOption("channel");
|
||||||
if (option == null) {
|
if (option == null) {
|
||||||
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
if (!TextChannelUtils.isValidChannel(profile.getChannelId())) {
|
||||||
|
@ -3,7 +3,7 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed;
|
|||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
@ -29,7 +29,7 @@ public class ResetSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class);
|
UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class);
|
||||||
profile.reset();
|
profile.reset();
|
||||||
guildService.saveGuild(guild);
|
guildService.saveGuild(guild);
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package cc.fascinated.bat.features.scoresaber.command.userfeed;
|
|||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatSubCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.GuildUserScoreFeedProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.guild.UserScoreFeedProfile;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import cc.fascinated.bat.service.GuildService;
|
import cc.fascinated.bat.service.GuildService;
|
||||||
@ -37,7 +37,7 @@ public class UserSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
GuildUserScoreFeedProfile profile = guild.getProfile(GuildUserScoreFeedProfile.class);
|
UserScoreFeedProfile profile = guild.getProfile(UserScoreFeedProfile.class);
|
||||||
OptionMapping option = interaction.getOption("user");
|
OptionMapping option = interaction.getOption("user");
|
||||||
if (option == null) {
|
if (option == null) {
|
||||||
if (profile.getTrackedUsers().isEmpty()) {
|
if (profile.getTrackedUsers().isEmpty()) {
|
||||||
@ -61,25 +61,28 @@ public class UserSubCommand extends BatSubCommand {
|
|||||||
|
|
||||||
User target = option.getAsUser();
|
User target = option.getAsUser();
|
||||||
BatUser targetUser = userService.getUser(target.getId());
|
BatUser targetUser = userService.getUser(target.getId());
|
||||||
UserScoreSaberProfile targetProfile = targetUser.getProfile(UserScoreSaberProfile.class);
|
ScoreSaberProfile targetProfile = targetUser.getScoreSaberProfile();
|
||||||
if (targetProfile.getSteamId() == null) {
|
if (targetProfile.getAccountId() == null) {
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||||
.setDescription("The user you are trying to track does not have a linked ScoreSaber profile")
|
.setDescription("The user you are trying to track does not have a linked ScoreSaber profile")
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getTrackedUsers().contains(targetProfile.getSteamId())) {
|
boolean added = false;
|
||||||
profile.getTrackedUsers().remove(targetProfile.getSteamId());
|
if (profile.isUserTracked(targetProfile.getAccountId())) {
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
profile.removeTrackedUser(targetProfile.getAccountId());
|
||||||
.setDescription("Successfully removed %s from the feed".formatted(target.getAsMention()))
|
|
||||||
.build()).queue();
|
|
||||||
} else {
|
} else {
|
||||||
profile.getTrackedUsers().add(targetProfile.getSteamId());
|
profile.addTrackedUser(targetProfile.getAccountId());
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
added = true;
|
||||||
.setDescription("Successfully added %s to the feed".formatted(target.getAsMention()))
|
|
||||||
.build()).queue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
||||||
|
.setDescription("Successfully %s %s from the feed".formatted(
|
||||||
|
added ? "added" : "removed",
|
||||||
|
target.getAsMention()
|
||||||
|
))
|
||||||
|
.build()).queue();
|
||||||
guildService.saveGuild(guild);
|
guildService.saveGuild(guild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cc.fascinated.bat.features.scoresaber.profile;
|
package cc.fascinated.bat.features.scoresaber.profile.guild;
|
||||||
|
|
||||||
import cc.fascinated.bat.common.Profile;
|
import cc.fascinated.bat.common.Profile;
|
||||||
import cc.fascinated.bat.service.DiscordService;
|
import cc.fascinated.bat.service.DiscordService;
|
||||||
@ -11,13 +11,13 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class GuildNumberOneScoreFeedProfile extends Profile {
|
public class NumberOneScoreFeedProfile extends Profile {
|
||||||
/**
|
/**
|
||||||
* The channel ID of the score feed
|
* The channel ID of the score feed
|
||||||
*/
|
*/
|
||||||
private String channelId;
|
private String channelId;
|
||||||
|
|
||||||
public GuildNumberOneScoreFeedProfile() {
|
public NumberOneScoreFeedProfile() {
|
||||||
super("scoresaber-number-one-score-feed");
|
super("scoresaber-number-one-score-feed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class GuildNumberOneScoreFeedProfile extends Profile {
|
|||||||
*
|
*
|
||||||
* @return the channel as a TextChannel
|
* @return the channel as a TextChannel
|
||||||
*/
|
*/
|
||||||
public TextChannel getAsTextChannel() {
|
public TextChannel getTextChannel() {
|
||||||
return DiscordService.JDA.getTextChannelById(channelId);
|
return DiscordService.JDA.getTextChannelById(channelId);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cc.fascinated.bat.features.scoresaber.profile;
|
package cc.fascinated.bat.features.scoresaber.profile.guild;
|
||||||
|
|
||||||
import cc.fascinated.bat.common.Profile;
|
import cc.fascinated.bat.common.Profile;
|
||||||
import cc.fascinated.bat.service.DiscordService;
|
import cc.fascinated.bat.service.DiscordService;
|
||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class GuildUserScoreFeedProfile extends Profile {
|
public class UserScoreFeedProfile extends Profile {
|
||||||
/**
|
/**
|
||||||
* The channel ID of the score feed
|
* The channel ID of the score feed
|
||||||
*/
|
*/
|
||||||
@ -25,20 +25,21 @@ public class GuildUserScoreFeedProfile extends Profile {
|
|||||||
*/
|
*/
|
||||||
private List<String> trackedUsers;
|
private List<String> trackedUsers;
|
||||||
|
|
||||||
public GuildUserScoreFeedProfile() {
|
public UserScoreFeedProfile() {
|
||||||
super("scoresaber-user-score-feed");
|
super("scoresaber-user-score-feed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tracked users
|
* Checks if a user is being tracked
|
||||||
*
|
*
|
||||||
* @return the tracked users
|
* @param userId the user ID to check
|
||||||
|
* @return if the user is being tracked
|
||||||
*/
|
*/
|
||||||
public List<String> getTrackedUsers() {
|
public boolean isUserTracked(String userId) {
|
||||||
if (this.trackedUsers == null) {
|
if (this.trackedUsers == null) {
|
||||||
this.trackedUsers = new ArrayList<>();
|
this.trackedUsers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return this.trackedUsers;
|
return trackedUsers.contains(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +71,7 @@ public class GuildUserScoreFeedProfile extends Profile {
|
|||||||
*
|
*
|
||||||
* @return the channel as a TextChannel
|
* @return the channel as a TextChannel
|
||||||
*/
|
*/
|
||||||
public TextChannel getAsTextChannel() {
|
public TextChannel getTextChannel() {
|
||||||
return DiscordService.JDA.getTextChannelById(channelId);
|
return DiscordService.JDA.getTextChannelById(channelId);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cc.fascinated.bat.features.scoresaber.profile;
|
package cc.fascinated.bat.features.scoresaber.profile.user;
|
||||||
|
|
||||||
import cc.fascinated.bat.common.Profile;
|
import cc.fascinated.bat.common.Profile;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -9,18 +9,18 @@ import lombok.Setter;
|
|||||||
*/
|
*/
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public class UserScoreSaberProfile extends Profile {
|
public class ScoreSaberProfile extends Profile {
|
||||||
/**
|
/**
|
||||||
* The Account ID of the ScoreSaber profile
|
* The Account ID of the ScoreSaber profile
|
||||||
*/
|
*/
|
||||||
private String steamId;
|
private String accountId;
|
||||||
|
|
||||||
public UserScoreSaberProfile() {
|
public ScoreSaberProfile() {
|
||||||
super("scoresaber");
|
super("scoresaber");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.steamId = null;
|
this.accountId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated.bat.model;
|
package cc.fascinated.bat.model;
|
||||||
|
|
||||||
import cc.fascinated.bat.common.ProfileHolder;
|
import cc.fascinated.bat.common.ProfileHolder;
|
||||||
|
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||||
import cc.fascinated.bat.service.DiscordService;
|
import cc.fascinated.bat.service.DiscordService;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -47,4 +48,13 @@ public class BatUser extends ProfileHolder {
|
|||||||
public User getDiscordUser() {
|
public User getDiscordUser() {
|
||||||
return DiscordService.JDA.getUserById(id);
|
return DiscordService.JDA.getUserById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the user's ScoreSaber profile
|
||||||
|
*
|
||||||
|
* @return the user's ScoreSaber profile
|
||||||
|
*/
|
||||||
|
public ScoreSaberProfile getScoreSaberProfile() {
|
||||||
|
return getProfile(ScoreSaberProfile.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import cc.fascinated.bat.common.WebRequest;
|
|||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.exception.BadRequestException;
|
import cc.fascinated.bat.exception.BadRequestException;
|
||||||
import cc.fascinated.bat.exception.ResourceNotFoundException;
|
import cc.fascinated.bat.exception.ResourceNotFoundException;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.user.ScoreSaberProfile;
|
||||||
import cc.fascinated.bat.model.token.beatsaber.scoresaber.*;
|
import cc.fascinated.bat.model.token.beatsaber.scoresaber.*;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -81,9 +81,9 @@ public class ScoreSaberService extends TextWebSocketHandler {
|
|||||||
* @param page The page to get the scores from.
|
* @param page The page to get the scores from.
|
||||||
* @return The scores.
|
* @return The scores.
|
||||||
*/
|
*/
|
||||||
public ScoreSaberScoresPageToken getPageScores(UserScoreSaberProfile profile, int page) {
|
public ScoreSaberScoresPageToken getPageScores(ScoreSaberProfile profile, int page) {
|
||||||
log.info("Fetching scores for account '{}' from page {}.", profile.getSteamId(), page);
|
log.info("Fetching scores for account '{}' from page {}.", profile.getAccountId(), page);
|
||||||
ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, profile.getSteamId(), "recent", page), ScoreSaberScoresPageToken.class);
|
ScoreSaberScoresPageToken pageToken = WebRequest.getAsEntity(String.format(GET_PLAYER_SCORES_ENDPOINT, profile.getAccountId(), "recent", page), ScoreSaberScoresPageToken.class);
|
||||||
if (pageToken == null) { // Check if the page doesn't exist.
|
if (pageToken == null) { // Check if the page doesn't exist.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -100,11 +100,11 @@ public class ScoreSaberService extends TextWebSocketHandler {
|
|||||||
* @param profile The profile.
|
* @param profile The profile.
|
||||||
* @return The scores.
|
* @return The scores.
|
||||||
*/
|
*/
|
||||||
public List<ScoreSaberScoresPageToken> getScores(UserScoreSaberProfile profile) {
|
public List<ScoreSaberScoresPageToken> getScores(ScoreSaberProfile profile) {
|
||||||
List<ScoreSaberScoresPageToken> scores = new ArrayList<>(List.of(getPageScores(profile, 1)));
|
List<ScoreSaberScoresPageToken> scores = new ArrayList<>(List.of(getPageScores(profile, 1)));
|
||||||
ScoreSaberPageMetadataToken metadata = scores.get(0).getMetadata();
|
ScoreSaberPageMetadataToken metadata = scores.get(0).getMetadata();
|
||||||
int totalPages = (int) Math.ceil((double) metadata.getTotal() / metadata.getItemsPerPage());
|
int totalPages = (int) Math.ceil((double) metadata.getTotal() / metadata.getItemsPerPage());
|
||||||
log.info("Fetching {} pages of scores for account '{}'.", totalPages, profile.getSteamId());
|
log.info("Fetching {} pages of scores for account '{}'.", totalPages, profile.getAccountId());
|
||||||
for (int i = 2; i <= totalPages; i++) {
|
for (int i = 2; i <= totalPages; i++) {
|
||||||
scores.add(getPageScores(profile, i));
|
scores.add(getPageScores(profile, i));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,9 @@ sentry:
|
|||||||
|
|
||||||
# MongoDB Migration Configuration
|
# MongoDB Migration Configuration
|
||||||
mongock:
|
mongock:
|
||||||
change-logs-scan-package: "cc.fascinated.bat.changelog"
|
runner-type: InitializingBean
|
||||||
|
migration-scan-package:
|
||||||
|
- "cc.fascinated.bat.changelog"
|
||||||
|
|
||||||
# Spotify Configuration
|
# Spotify Configuration
|
||||||
spotify:
|
spotify:
|
||||||
|
Loading…
Reference in New Issue
Block a user