From 5b1ddb145f2ffe894e6c3d7bc8b678c774b51eb8 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 30 Jun 2024 07:41:31 +0100 Subject: [PATCH] make feature command less ugly and update feature disabled message --- .../bat/features/command/DisableSubCommand.java | 16 ++++++++++++---- .../bat/features/command/EnableSubCommand.java | 16 ++++++++++++---- .../fascinated/bat/service/CommandService.java | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java b/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java index ca9fc0d..63f926c 100644 --- a/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/command/DisableSubCommand.java @@ -37,22 +37,30 @@ public class DisableSubCommand extends BatSubCommand { FeatureProfile featureProfile = guild.getFeatureProfile(); OptionMapping featureOption = interaction.getOption("feature"); if (featureOption == null) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("You must provide a feature to disable").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("You must provide a feature to disable") + .build()).queue(); return; } String featureName = featureOption.getAsString(); if (!FeatureService.INSTANCE.isFeature(featureName)) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("That feature does not exist").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("That feature does not exist") + .build()).queue(); return; } Feature feature = FeatureService.INSTANCE.getFeature(featureName); if (featureProfile.isFeatureDisabled(feature)) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("That feature is already disabled").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("The feature `%s` is already disabled".formatted(feature.getName())) + .build()).queue(); return; } featureProfile.setFeatureState(feature, true); guildService.saveGuild(guild); - interaction.replyEmbeds(EmbedUtils.successEmbed().setDescription("Successfully disabled the feature " + feature.getName()).build()).queue(); + interaction.replyEmbeds(EmbedUtils.successEmbed() + .setDescription("Successfully disabled the `%s` feature".formatted(feature.getName())) + .build()).queue(); } } diff --git a/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java b/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java index 7346466..9313188 100644 --- a/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/command/EnableSubCommand.java @@ -37,22 +37,30 @@ public class EnableSubCommand extends BatSubCommand { FeatureProfile featureProfile = guild.getFeatureProfile(); OptionMapping featureOption = interaction.getOption("feature"); if (featureOption == null) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("You must provide a feature to enable").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("You must provide a feature to enabled") + .build()).queue(); return; } String featureName = featureOption.getAsString(); if (!FeatureService.INSTANCE.isFeature(featureName)) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("That feature does not exist").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("That feature does not exist") + .build()).queue(); return; } Feature feature = FeatureService.INSTANCE.getFeature(featureName); if (!featureProfile.isFeatureDisabled(feature)) { - interaction.replyEmbeds(EmbedUtils.errorEmbed().setDescription("That feature is already enabled").build()).queue(); + interaction.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("The feature `%s` is already enabled".formatted(feature.getName())) + .build()).queue(); return; } featureProfile.setFeatureState(feature, false); guildService.saveGuild(guild); - interaction.replyEmbeds(EmbedUtils.successEmbed().setDescription("Successfully enabled the feature " + feature.getName()).build()).queue(); + interaction.replyEmbeds(EmbedUtils.successEmbed() + .setDescription("Successfully enabled the `%s` feature".formatted(feature.getName())) + .build()).queue(); } } diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index e7da293..19b1d08 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -224,7 +224,7 @@ public class CommandService extends ListenerAdapter { FeatureProfile featureProfile = guild.getFeatureProfile(); if (featureProfile.isFeatureDisabled(command.getFeature())) { event.replyEmbeds(EmbedUtils.errorEmbed() - .setDescription("This command has been disabled by the guild owner") + .setDescription("The feature `%s` is disabled in this guild".formatted(command.getFeature().getName())) .build()).setEphemeral(true).queue(); return; }