update scoresaber command messages
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m0s

This commit is contained in:
Lee 2024-07-04 15:42:16 +01:00
parent 7abdcd4d95
commit 9a5609f40e
4 changed files with 47 additions and 35 deletions

@ -37,7 +37,9 @@ public class LinkSubCommand extends BatCommand {
if (option == null) { if (option == null) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Please provide a ScoreSaber profile link") .setDescription("Please provide a ScoreSaber profile link")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
@ -45,7 +47,9 @@ public class LinkSubCommand extends BatCommand {
if (!link.contains("scoresaber.com/u/")) { if (!link.contains("scoresaber.com/u/")) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Invalid ScoreSaber profile link") .setDescription("Invalid ScoreSaber profile link")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
@ -58,13 +62,17 @@ public class LinkSubCommand extends BatCommand {
if (account == null) { if (account == null) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Invalid ScoreSaber profile link") .setDescription("Invalid ScoreSaber profile link")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
user.getScoreSaberProfile().setAccountId(id); user.getScoreSaberProfile().setAccountId(id);
event.replyEmbeds(EmbedUtils.successEmbed() event.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)))
.build()).queue(); .build())
.setEphemeral(true)
.queue();
} }
} }

@ -24,7 +24,9 @@ public class ResetSubCommand extends BatCommand {
profile.reset(); profile.reset();
event.replyEmbeds(EmbedUtils.successEmbed() event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("Successfully reset your settings.") .setDescription("Successfully reset your settings.")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
} }
} }

@ -28,14 +28,10 @@ import java.time.LocalDateTime;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "scoresaber", description = "General ScoreSaber commands", guildOnly = false, userInstall = true, category = Category.BEAT_SABER) @CommandInfo(name = "scoresaber", description = "General ScoreSaber commands", userInstall = true, category = Category.BEAT_SABER)
public class ScoreSaberCommand extends BatCommand { public class ScoreSaberCommand extends BatCommand {
private final ScoreSaberService scoreSaberService;
@Autowired @Autowired
public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull ApplicationContext context) { public ScoreSaberCommand(@NonNull ApplicationContext context) {
this.scoreSaberService = scoreSaberService;
super.addSubCommands( super.addSubCommands(
context.getBean(LinkSubCommand.class), context.getBean(LinkSubCommand.class),
context.getBean(UserSubCommand.class), context.getBean(UserSubCommand.class),
@ -56,12 +52,16 @@ public class ScoreSaberCommand extends BatCommand {
if (profile.getAccountId() == 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()))
.build()).queue(); .build())
.setEphemeral(true)
.queue();
} }
interaction.replyEmbeds(EmbedUtils.errorEmbed() interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You do not have a linked ScoreSaber account") .setDescription("You do not have a linked ScoreSaber account")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
@ -71,13 +71,17 @@ public class ScoreSaberCommand extends BatCommand {
if (account == null) { if (account == null) {
if (!isSelf) { if (!isSelf) {
interaction.replyEmbeds(EmbedUtils.errorEmbed() interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("%s has an invalid ScoreSaber account linked, please ask them to re-link their account" .setDescription("%s has an invalid ScoreSaber account linked, please ask them to re-link their account"
.formatted(user.getDiscordUser().getAsMention())) .formatted(user.getDiscordUser().getAsMention()))
.build()).queue(); .build())
.setEphemeral(true)
.queue();
} }
interaction.replyEmbeds(EmbedUtils.errorEmbed() interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You have an invalid ScoreSaber account linked, please re-link your account") .setDescription("You have an invalid ScoreSaber account linked, please re-link your account")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
@ -97,13 +101,10 @@ public class ScoreSaberCommand extends BatCommand {
.build()).queue(); .build()).queue();
} catch (RateLimitException ex) { } catch (RateLimitException ex) {
interaction.replyEmbeds(EmbedUtils.errorEmbed() interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("The ScoreSaber API is currently rate our limiting requests, please try again later") .setDescription("The ScoreSaber API is currently rate our limiting requests, please try again later")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
} }
} }
@Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
sendProfileEmbed(true, user, scoreSaberService, event);
}
} }

@ -37,24 +37,25 @@ public class UserSubCommand extends BatCommand {
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
OptionMapping option = event.getOption("user"); OptionMapping option = event.getOption("user");
if (option == null) { if (option == null) {
event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Please provide a user to view the ScoreSaber profile of")
.build()).queue();
return; return;
} }
if (option.getAsUser().isBot()) { if (option.getAsUser().isBot()) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You cannot view the ScoreSaber profile for a Bot") .setDescription("You cannot view the ScoreSaber profile for a Bot")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
BatUser target = userService.getUser(option.getAsUser().getId()); BatUser target = userService.getUser(option.getAsUser().getId());
if (target == null) { if (target == null) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Unknown user") .setDescription("Unknown user")
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
ScoreSaberCommand.sendProfileEmbed(false, target, scoreSaberService, event); ScoreSaberCommand.sendProfileEmbed(false, target, scoreSaberService, event);