mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-08 18:34:05 +00:00
[AB-xxx] fixing custom command alternative to filter when it should be executed more accurately
This commit is contained in:
@@ -166,7 +166,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
if(commandAlternatives != null) {
|
||||
Optional<CommandAlternative> foundAlternativeOptional = commandAlternatives
|
||||
.stream()
|
||||
.filter(commandAlternative -> commandAlternative.shouldExecute(result.getParameter(), event.getGuild()))
|
||||
.filter(commandAlternative -> commandAlternative.shouldExecute(result.getParameter(), event.getGuild(), message))
|
||||
.findFirst();
|
||||
if(foundAlternativeOptional.isPresent()) {
|
||||
CommandAlternative foundAlternative = foundAlternativeOptional.get();
|
||||
@@ -584,7 +584,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
metricService.registerCounter(COMMANDS_WRONG_PARAMETER_COUNTER, "Commands with incorrect parameter");
|
||||
this.parameterHandlers = parameterHandlers.stream().sorted(comparing(CommandParameterHandler::getPriority)).collect(Collectors.toList());
|
||||
if(commandAlternatives != null) {
|
||||
this.commandAlternatives = commandAlternatives.stream().sorted(comparing(Prioritized::getPriority)).collect(Collectors.toList());
|
||||
this.commandAlternatives = commandAlternatives.stream().sorted(comparing(Prioritized::getPriority).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
public interface CommandAlternative extends Prioritized {
|
||||
boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild);
|
||||
boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message);
|
||||
void execute(UnParsedCommandParameter parameter, Message message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user