mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-25 05:57:06 +00:00
[AB-55] fixing custom command not considering feature flag
ignoring case for custom command
This commit is contained in:
@@ -5,11 +5,14 @@ import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
|
||||
import dev.sheldan.abstracto.core.command.service.CommandRegistry;
|
||||
import dev.sheldan.abstracto.core.config.ListenerPriority;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.customcommand.config.CustomCommandFeatureConfig;
|
||||
import dev.sheldan.abstracto.customcommand.model.command.CustomCommandResponseModel;
|
||||
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandManagementService;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -35,9 +38,15 @@ public class CustomCommandAlternative implements CommandAlternative {
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@Autowired
|
||||
private FeatureFlagService featureFlagService;
|
||||
|
||||
@Autowired
|
||||
private CustomCommandFeatureConfig customCommandFeatureConfig;
|
||||
|
||||
@Override
|
||||
public boolean matches(UnParsedCommandParameter parameter) {
|
||||
return true;
|
||||
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild) {
|
||||
return featureFlagService.isFeatureEnabled(customCommandFeatureConfig, guild.getIdLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,5 +9,5 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CustomCommandRepository extends JpaRepository<CustomCommand, Long> {
|
||||
Optional<CustomCommand> getByNameAndServer(String name, AServer server);
|
||||
Optional<CustomCommand> getByNameIgnoreCaseAndServer(String name, AServer server);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ public class CustomCommandManagementServiceBean implements CustomCommandManageme
|
||||
@Override
|
||||
public Optional<CustomCommand> getCustomCommandByName(String name, Long serverId) {
|
||||
AServer server = serverManagementService.loadServer(serverId);
|
||||
return repository.getByNameAndServer(name, server);
|
||||
return repository.getByNameIgnoreCaseAndServer(name, server);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user