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

@ -28,14 +28,10 @@ import java.time.LocalDateTime;
* @author Fascinated (fascinated7)
*/
@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 {
private final ScoreSaberService scoreSaberService;
@Autowired
public ScoreSaberCommand(@NonNull ScoreSaberService scoreSaberService, @NonNull ApplicationContext context) {
this.scoreSaberService = scoreSaberService;
public ScoreSaberCommand(@NonNull ApplicationContext context) {
super.addSubCommands(
context.getBean(LinkSubCommand.class),
context.getBean(UserSubCommand.class),
@ -56,12 +52,16 @@ public class ScoreSaberCommand extends BatCommand {
if (profile.getAccountId() == null) {
if (!isSelf) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("%s does not have a linked ScoreSaber account".formatted(user.getDiscordUser().getAsMention()))
.build()).queue();
.setDescription("%s does not have a linked ScoreSaber account".formatted(user.getDiscordUser().getAsMention()))
.build())
.setEphemeral(true)
.queue();
}
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You do not have a linked ScoreSaber account")
.build()).queue();
.setDescription("You do not have a linked ScoreSaber account")
.build())
.setEphemeral(true)
.queue();
return;
}
@ -71,13 +71,17 @@ public class ScoreSaberCommand extends BatCommand {
if (account == null) {
if (!isSelf) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("%s has an invalid ScoreSaber account linked, please ask them to re-link their account"
.formatted(user.getDiscordUser().getAsMention()))
.build()).queue();
.setDescription("%s has an invalid ScoreSaber account linked, please ask them to re-link their account"
.formatted(user.getDiscordUser().getAsMention()))
.build())
.setEphemeral(true)
.queue();
}
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You have an invalid ScoreSaber account linked, please re-link your account")
.build()).queue();
.setDescription("You have an invalid ScoreSaber account linked, please re-link your account")
.build())
.setEphemeral(true)
.queue();
return;
}
@ -97,13 +101,10 @@ public class ScoreSaberCommand extends BatCommand {
.build()).queue();
} catch (RateLimitException ex) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("The ScoreSaber API is currently rate our limiting requests, please try again later")
.build()).queue();
.setDescription("The ScoreSaber API is currently rate our limiting requests, please try again later")
.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) {
OptionMapping option = event.getOption("user");
if (option == null) {
event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Please provide a user to view the ScoreSaber profile of")
.build()).queue();
return;
}
if (option.getAsUser().isBot()) {
event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You cannot view the ScoreSaber profile for a Bot")
.build()).queue();
.setDescription("You cannot view the ScoreSaber profile for a Bot")
.build())
.setEphemeral(true)
.queue();
return;
}
BatUser target = userService.getUser(option.getAsUser().getId());
if (target == null) {
event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Unknown user")
.build()).queue();
.setDescription("Unknown user")
.build())
.setEphemeral(true)
.queue();
return;
}
ScoreSaberCommand.sendProfileEmbed(false, target, scoreSaberService, event);