mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-24 05:10:24 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class TemplateServiceBeanTest {
|
||||
@Mock
|
||||
private ConfigService configService;
|
||||
|
||||
// requires the org.mockito.plugins.MockMaker file
|
||||
@Mock
|
||||
private Gson gson;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user