add checks for some events to see if the feature is enabled and more cleanup
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s

This commit is contained in:
Lee
2024-06-30 08:24:14 +01:00
parent 22d4558d84
commit 6403c57db5
9 changed files with 74 additions and 6 deletions

View File

@ -50,7 +50,7 @@ public class DisableSubCommand extends BatSubCommand {
return;
}
Feature feature = FeatureService.INSTANCE.getFeature(featureName);
if (featureProfile.getFeatureState(feature) == FeatureProfile.FeatureState.DISABLED) {
if (featureProfile.isFeatureDisabled(feature)) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("The feature `%s` is already enabled".formatted(feature.getName()))
.build()).queue();

View File

@ -50,7 +50,7 @@ public class EnableSubCommand extends BatSubCommand {
return;
}
Feature feature = FeatureService.INSTANCE.getFeature(featureName);
if (featureProfile.getFeatureState(feature) == FeatureProfile.FeatureState.ENABLED) {
if (featureProfile.isFeatureEnabled(feature)) {
interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("The feature `%s` is already enabled".formatted(feature.getName()))
.build()).queue();

View File

@ -40,6 +40,24 @@ public class FeatureProfile extends Profile {
return this.featureStates.get(featureName);
}
/**
* Gets whether the feature is enabled
*
* @return the feature state
*/
public boolean isFeatureEnabled(Feature feature) {
return this.getFeatureState(feature) == FeatureState.ENABLED;
}
/**
* Gets whether the feature is disabled
*
* @return the feature state
*/
public boolean isFeatureDisabled(Feature feature) {
return this.getFeatureState(feature) == FeatureState.DISABLED;
}
/**
* Enables the feature
*