[AB-97] adding react command

we are now actively loading messages in case its a parameter, because the provided message is only partially available
This commit is contained in:
Sheldan
2021-04-13 23:47:22 +02:00
parent 23379e4498
commit 537fd85be8
36 changed files with 820 additions and 22 deletions

View File

@@ -5,15 +5,27 @@ import dev.sheldan.abstracto.core.command.CommandConstants;
import dev.sheldan.abstracto.core.command.config.Parameter;
import dev.sheldan.abstracto.core.command.execution.UnparsedCommandParameterPiece;
import dev.sheldan.abstracto.core.command.handler.provided.MessageParameterHandler;
import dev.sheldan.abstracto.core.service.MessageService;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
@Component
public class MessageParameterHandlerImpl implements MessageParameterHandler {
@Autowired
private MessageService messageService;
@Override
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return context.getReferencedMessage();
public CompletableFuture<Object> handleAsync(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
return messageService.loadMessage(context.getReferencedMessage()).thenApply(message -> message);
}
@Override
public boolean async() {
return true;
}
@Override

View File

@@ -194,6 +194,11 @@ public class MessageServiceBean implements MessageService {
return channelService.retrieveMessageInChannel(serverId, channelId, messageId);
}
@Override
public CompletableFuture<Message> loadMessage(Message message) {
return loadMessage(message.getGuild().getIdLong(), message.getChannel().getIdLong(), message.getIdLong());
}
@Override
public MessageAction editMessage(Message message, MessageEmbed messageEmbed) {
metricService.incrementCounter(MESSAGE_EDIT_METRIC);

View File

@@ -59,6 +59,7 @@ public class TemplateServiceBeanTest {
@Mock
private ConfigService configService;
// requires the org.mockito.plugins.MockMaker file
@Mock
private Gson gson;