Compare commits

..

15 Commits

Author SHA1 Message Date
Sheldan
46bf4fbc42 [AB-xxx] changing the method used to edit the giveaway message 2025-08-02 00:06:43 +02:00
Sheldan
97ac25dbb6 [AB-xxx] adding auto complete for feature names/feature mode names 2025-08-01 23:52:15 +02:00
Sheldan
ef4bdb2ab2 [AB-xxx] enabling commands which take users to only require one parameter instead of a string and a member option 2025-07-29 23:04:33 +02:00
release-bot
433fdb7068 Commit from GitHub Actions (Publishes a new version of abstracto) 2025-07-20 09:04:03 +00:00
release-bot
e59b6269e1 [maven-release-plugin] prepare for next development iteration 2025-07-20 08:49:59 +00:00
release-bot
8077501584 [maven-release-plugin] prepare release v1.6.11 2025-07-20 08:49:57 +00:00
Sheldan
cb9ab8f542 [AB-xxx] adding ability to define unique ids for components, a color of the container, disabled state for multiple components and spoiler for container
fixing reminder message not containing a link to the message anymore
2025-07-19 23:56:06 +02:00
release-bot
f513f8890b Commit from GitHub Actions (Publishes a new version of abstracto) 2025-07-13 20:08:48 +00:00
release-bot
6f02834b75 [maven-release-plugin] prepare for next development iteration 2025-07-13 19:56:17 +00:00
release-bot
75456b45c9 [maven-release-plugin] prepare release v1.6.10 2025-07-13 19:56:15 +00:00
Sheldan
92e581305e [AB-xxx] changing logic to replace embedded messages with the link instead of removing the reaction/button for deletion 2025-07-13 21:52:37 +02:00
release-bot
bd8b57e977 Commit from GitHub Actions (Publishes a new version of abstracto) 2025-07-13 18:05:19 +00:00
release-bot
e5fc411dc2 [maven-release-plugin] prepare for next development iteration 2025-07-13 17:52:51 +00:00
release-bot
9d9fdef42e [maven-release-plugin] prepare release v1.6.9 2025-07-13 17:52:49 +00:00
Sheldan
4a3d43b1b0 [AB-xxx] adding initial support for components v2
fixing issue with buttons which only provide an emoji
adding logging in case updating a starboard post goes wrong
2025-07-13 19:45:59 +02:00
105 changed files with 393 additions and 201 deletions

2
.env
View File

@@ -1,2 +1,2 @@
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/ REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.6.8 VERSION=1.6.11

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>anti-raid</artifactId> <artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>anti-raid</artifactId> <artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId> <artifactId>assignable-roles</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId> <artifactId>assignable-roles</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>assignable-roles-int</artifactId> <artifactId>assignable-roles-int</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>custom-command</artifactId> <artifactId>custom-command</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>custom-command</artifactId> <artifactId>custom-command</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>dynamic-activity</artifactId> <artifactId>dynamic-activity</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>dynamic-activity</artifactId> <artifactId>dynamic-activity</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>entertainment</artifactId> <artifactId>entertainment</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>entertainment</artifactId> <artifactId>entertainment</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>experience-tracking</artifactId> <artifactId>experience-tracking</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>experience-tracking</artifactId> <artifactId>experience-tracking</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway-impl</artifactId> <artifactId>giveaway-impl</artifactId>

View File

@@ -155,7 +155,7 @@ public class GiveawayServiceBean implements GiveawayService {
Long giveawayId = giveaway.getGiveawayId().getId(); Long giveawayId = giveaway.getGiveawayId().getId();
log.info("Adding giveaway participating of user {} to giveaway {} in server {}.", member.getIdLong(), giveawayId, member.getGuild().getIdLong()); log.info("Adding giveaway participating of user {} to giveaway {} in server {}.", member.getIdLong(), giveawayId, member.getGuild().getIdLong());
MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel, member.getGuild().getIdLong()); MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel, member.getGuild().getIdLong());
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), messageChannel, giveaway.getMessageId()) return channelService.editMessageInAChannelFuture(messageToSend, messageChannel, giveaway.getMessageId())
.thenAccept(message -> { .thenAccept(message -> {
self.persistAddedParticipant(member, giveawayId); self.persistAddedParticipant(member, giveawayId);
}); });

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway-int</artifactId> <artifactId>giveaway-int</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation-impl</artifactId> <artifactId>image-generation-impl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation-int</artifactId> <artifactId>image-generation-int</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>invite-filter</artifactId> <artifactId>invite-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>invite-filter</artifactId> <artifactId>invite-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation-int</artifactId> <artifactId>moderation-int</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>link-embed</artifactId> <artifactId>link-embed</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -11,6 +11,7 @@ import dev.sheldan.abstracto.core.interaction.button.ButtonConfigModel;
import dev.sheldan.abstracto.core.interaction.ComponentPayloadManagementService; import dev.sheldan.abstracto.core.interaction.ComponentPayloadManagementService;
import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureDefinition; import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureDefinition;
import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureMode; import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureMode;
import dev.sheldan.abstracto.linkembed.model.template.MessageEmbedCleanupReplacementModel;
import dev.sheldan.abstracto.linkembed.model.template.MessageEmbedDeleteButtonPayload; import dev.sheldan.abstracto.linkembed.model.template.MessageEmbedDeleteButtonPayload;
import dev.sheldan.abstracto.linkembed.model.template.MessageEmbeddedModel; import dev.sheldan.abstracto.linkembed.model.template.MessageEmbeddedModel;
import dev.sheldan.abstracto.core.service.*; import dev.sheldan.abstracto.core.service.*;
@@ -18,7 +19,6 @@ import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService; import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend; import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService; import dev.sheldan.abstracto.core.templating.service.TemplateService;
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
import dev.sheldan.abstracto.core.utils.FutureUtils; import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.abstracto.linkembed.model.MessageEmbedLink; import dev.sheldan.abstracto.linkembed.model.MessageEmbedLink;
import dev.sheldan.abstracto.linkembed.model.database.EmbeddedMessage; import dev.sheldan.abstracto.linkembed.model.database.EmbeddedMessage;
@@ -28,6 +28,7 @@ import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.CommandInteraction; import net.dv8tion.jda.api.interactions.commands.CommandInteraction;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -49,6 +50,7 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
private final Pattern messageRegex = Pattern.compile("(?<whole>(?:https?://)?(?:\\w+\\.)?discord(?:app)?\\.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+", Pattern.CASE_INSENSITIVE); private final Pattern messageRegex = Pattern.compile("(?<whole>(?:https?://)?(?:\\w+\\.)?discord(?:app)?\\.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+", Pattern.CASE_INSENSITIVE);
public static final String MESSAGE_EMBED_TEMPLATE = "message_embed"; public static final String MESSAGE_EMBED_TEMPLATE = "message_embed";
private static final String MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE = "message_embed_cleanup_replacement";
public static final String REMOVAL_EMOTE = "removeEmbed"; public static final String REMOVAL_EMOTE = "removeEmbed";
@Autowired @Autowired
@@ -78,9 +80,6 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
@Autowired @Autowired
private ReactionService reactionService; private ReactionService reactionService;
@Autowired
private MessageService messageService;
@Autowired @Autowired
private ComponentService componentServiceBean; private ComponentService componentServiceBean;
@@ -160,15 +159,21 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }
log.info("Cleaning up {} embedded embeddedMessages", embeddedMessages.size()); log.info("Cleaning up {} embedded embeddedMessages", embeddedMessages.size());
List<ServerChannelMessage> reactionChannelMessages = embeddedMessages.stream() List<Pair<ServerChannelMessage, ServerChannelMessage>> embeddingMessages = embeddedMessages.stream()
.filter(embeddedMessage -> embeddedMessage.getDeletionComponentId() == null) .map(embeddedMessage -> Pair.of(ServerChannelMessage
.map(this::convertEmbedMessageToServerChannelMessage) .builder()
.collect(Collectors.toList()); .serverId(embeddedMessage.getEmbeddingServer().getId())
.channelId(embeddedMessage.getEmbeddingChannel().getId())
.messageId(embeddedMessage.getEmbeddingMessageId())
.build(),
ServerChannelMessage
.builder().
serverId(embeddedMessage.getEmbeddedServer().getId())
.channelId(embeddedMessage.getEmbeddedChannel().getId())
.messageId(embeddedMessage.getEmbeddedMessageId())
.build()))
.toList();
List<ServerChannelMessage> buttonChannelMessages = embeddedMessages.stream()
.filter(embeddedMessage -> embeddedMessage.getDeletionComponentId() != null)
.map(this::convertEmbedMessageToServerChannelMessage)
.collect(Collectors.toList());
List<Long> embeddedMessagesHandled = embeddedMessages List<Long> embeddedMessagesHandled = embeddedMessages
.stream() .stream()
.map(EmbeddedMessage::getEmbeddingMessageId) .map(EmbeddedMessage::getEmbeddingMessageId)
@@ -179,67 +184,26 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
.filter(Objects::nonNull) .filter(Objects::nonNull)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
List<CompletableFuture<Message>> reactionMessageFutures = messageService.retrieveMessages(reactionChannelMessages); List<CompletableFuture<Message>> editList = embeddingMessages.stream().map(messagePair -> {
List<CompletableFuture<Message>> buttonMessageFutures = messageService.retrieveMessages(buttonChannelMessages); ServerChannelMessage embeddingMessage = messagePair.getLeft();
CompletableFutureList<Message> reactionFutureList = new CompletableFutureList<>(reactionMessageFutures); ServerChannelMessage embeddedMessage = messagePair.getRight();
CompletableFutureList<Message> buttonFutureList = new CompletableFutureList<>(buttonMessageFutures); MessageEmbedCleanupReplacementModel model = MessageEmbedCleanupReplacementModel
return reactionFutureList.getMainFuture()
.handle((unused, throwable) -> {
if(throwable != null) {
log.warn("Embedded messages reaction message loading failed.", throwable);
}
return self.removeReactions(reactionFutureList.getObjects());
})
.thenCompose(Function.identity())
.thenCompose(unused -> buttonFutureList.getMainFuture())
.handle((unused, throwable) -> {
if(throwable != null) {
log.warn("Embedded messages button message loading failed.", throwable);
}
return self.removeButtons(buttonFutureList.getObjects());
})
// deleting the messages from db regardless of exceptions, at most the reaction remains
.thenCompose(Function.identity())
.whenComplete((unused, throwable) -> {
if(throwable != null) {
log.warn("Embedded message button clearing failed.", throwable);
}
self.deleteEmbeddedMessages(embeddedMessagesHandled, componentPayloadsToDelete);
})
.exceptionally(throwable -> {
log.error("Failed to clean up embedded messages.", throwable);
return null;
});
}
public CompletableFuture<Void> removeButtons(List<Message> messages) {
List<CompletableFuture<Void>> removalFutures = new ArrayList<>();
messages.forEach(message -> removalFutures.add(componentServiceBean.clearButtons(message)));
return FutureUtils.toSingleFutureGeneric(removalFutures);
}
private ServerChannelMessage convertEmbedMessageToServerChannelMessage(EmbeddedMessage embeddedMessage) {
return ServerChannelMessage
.builder() .builder()
.serverId(embeddedMessage.getEmbeddingServer().getId()) .message(embeddedMessage)
.channelId(embeddedMessage.getEmbeddingChannel().getId())
.messageId(embeddedMessage.getEmbeddingMessageId())
.build(); .build();
MessageToSend messageToSend =
templateService.renderEmbedTemplate(MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE, model, embeddingMessage.getServerId());
return channelService.editMessageInAChannelFuture(messageToSend, embeddingMessage.getServerId(), embeddingMessage.getChannelId(),
embeddingMessage.getMessageId());
}).toList();
return FutureUtils.toSingleFutureGeneric(editList).whenComplete((unused, throwable) -> {
if(throwable != null) {
log.warn("Failed to cleanup embedded messages..", throwable);
}
self.deleteEmbeddedMessages(embeddedMessagesHandled, componentPayloadsToDelete);
});
} }
@Transactional
public CompletableFuture<Void> removeReactions(List<Message> allMessages) {
List<CompletableFuture<Void>> removalFutures = new ArrayList<>();
Map<Long, List<Message>> groupedPerServer = allMessages
.stream()
.collect(Collectors.groupingBy(message -> message.getGuild().getIdLong()));
groupedPerServer.forEach((serverId, serverMessages) -> {
// we assume the emote remained the same
CompletableFutureList<Void> removalFuture = reactionService.removeReactionFromMessagesWithFutureWithFutureList(serverMessages, REMOVAL_EMOTE);
removalFutures.add(removalFuture.getMainFuture());
});
return FutureUtils.toSingleFutureGeneric(removalFutures);
}
@Transactional @Transactional
public void deleteEmbeddedMessages(List<Long> embeddedMessagesToDelete, List<String> componentPayloadsToDelete) { public void deleteEmbeddedMessages(List<Long> embeddedMessagesToDelete, List<String> componentPayloadsToDelete) {

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>link-embed</artifactId> <artifactId>link-embed</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -0,0 +1,11 @@
package dev.sheldan.abstracto.linkembed.model.template;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
public class MessageEmbedCleanupReplacementModel {
private ServerChannelMessage message;
}

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>logging</artifactId> <artifactId>logging</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>logging</artifactId> <artifactId>logging</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation</artifactId> <artifactId>moderation</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -23,7 +23,6 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.InteractionHook; import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -76,16 +75,15 @@ public class Ban extends AbstractConditionableCommand {
duration = null; duration = null;
} }
if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.USER)) { Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class);
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class); if(member != null) {
return event.deferReply().submit() return event.deferReply().submit()
.thenCompose((hook) -> self.banMember(event, member, reason, duration, hook)) .thenCompose((hook) -> self.banMember(event, member, reason, duration, hook))
.thenApply(commandResult -> CommandResult.fromSuccess()); .thenApply(commandResult -> CommandResult.fromSuccess());
} else { } else {
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class); User user = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, User.class);
Long userId = Long.parseLong(userIdStr);
return event.deferReply().submit() return event.deferReply().submit()
.thenCompose((hook) -> self.banViaUserId(event, userId, reason, duration, hook)) .thenCompose((hook) -> self.banViaUserId(event, user.getIdLong(), reason, duration, hook))
.thenApply(commandResult -> CommandResult.fromSuccess()); .thenApply(commandResult -> CommandResult.fromSuccess());
} }
} }

View File

@@ -33,7 +33,6 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.InteractionHook; import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -86,16 +85,15 @@ public class Infractions extends AbstractConditionableCommand {
public CompletableFuture<CommandResult> showInfractions(InteractionHook hook, SlashCommandInteractionEvent event) { public CompletableFuture<CommandResult> showInfractions(InteractionHook hook, SlashCommandInteractionEvent event) {
List<Infraction> infractions; List<Infraction> infractions;
Guild guild = hook.getInteraction().getGuild(); Guild guild = hook.getInteraction().getGuild();
if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.USER)) { Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class);
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class); User user = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, User.class);
if(member != null) {
if(!member.getGuild().equals(guild)) { if(!member.getGuild().equals(guild)) {
throw new EntityGuildMismatchException(); throw new EntityGuildMismatchException();
} }
infractions = infractionManagementService.getInfractionsForUser(userInServerManagementService.loadOrCreateUser(member)); infractions = infractionManagementService.getInfractionsForUser(userInServerManagementService.loadOrCreateUser(member));
} else if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.STRING)){ } else if(user != null){
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class); AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), user.getIdLong());
Long userId = Long.parseLong(userIdStr);
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), userId);
infractions = infractionManagementService.getInfractionsForUser(userInServer); infractions = infractionManagementService.getInfractionsForUser(userInServer);
} else { } else {

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation</artifactId> <artifactId>moderation</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>modmail</artifactId> <artifactId>modmail</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>modmail</artifactId> <artifactId>modmail</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto</groupId> <groupId>dev.sheldan.abstracto</groupId>
<artifactId>abstracto-application</artifactId> <artifactId>abstracto-application</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>profanity-filter</artifactId> <artifactId>profanity-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>profanity-filter</artifactId> <artifactId>profanity-filter</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>remind</artifactId> <artifactId>remind</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -223,6 +223,9 @@ public class RemindServiceBean implements ReminderService {
.builder() .builder()
.reminderParticipants(participantsDisplays) .reminderParticipants(participantsDisplays)
.reminderDisplay(reminderDisplay) .reminderDisplay(reminderDisplay)
.serverId(reminder.getServer().getId())
.channelId(reminder.getChannel().getId())
.messageId(reminder.getMessageId())
.userDisplay(UserDisplay.fromUser(member.getUser())) .userDisplay(UserDisplay.fromUser(member.getUser()))
.duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate())) .duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate()))
.build(); .build();

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>remind</artifactId> <artifactId>remind</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>repost-detection</artifactId> <artifactId>repost-detection</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>repost-detection</artifactId> <artifactId>repost-detection</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>starboard</artifactId> <artifactId>starboard</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>starboard</artifactId> <artifactId>starboard</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>statistic</artifactId> <artifactId>statistic</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>statistic</artifactId> <artifactId>statistic</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>sticky-roles</artifactId> <artifactId>sticky-roles</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>sticky-roles-impl</artifactId> <artifactId>sticky-roles-impl</artifactId>

View File

@@ -11,7 +11,6 @@ import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService; import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.service.UserService;
import dev.sheldan.abstracto.stickyroles.config.StickyRolesFeatureDefinition; import dev.sheldan.abstracto.stickyroles.config.StickyRolesFeatureDefinition;
import dev.sheldan.abstracto.stickyroles.config.StickyRolesSlashCommandNames; import dev.sheldan.abstracto.stickyroles.config.StickyRolesSlashCommandNames;
import dev.sheldan.abstracto.stickyroles.service.StickyRoleService; import dev.sheldan.abstracto.stickyroles.service.StickyRoleService;
@@ -19,10 +18,8 @@ import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -47,34 +44,18 @@ public class ToggleStickinessManagement extends AbstractConditionableCommand {
@Autowired @Autowired
private StickyRoleService stickyRoleService; private StickyRoleService stickyRoleService;
@Autowired
private UserService userService;
@Autowired
private ToggleStickinessManagement self;
@Override @Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) { public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
Boolean newState = slashCommandParameterService.getCommandOption(STICKY_PARAMETER_NAME, event, Boolean.class); Boolean newState = slashCommandParameterService.getCommandOption(STICKY_PARAMETER_NAME, event, Boolean.class);
if(slashCommandParameterService.hasCommandOptionWithFullType(MEMBER_PARAMETER_NAME, event, OptionType.USER)) { Member targetMember = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, Member.class);
Member targetMember = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, Member.class); User targetUser = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, User.class);
if(targetMember != null) {
stickyRoleService.setStickiness(targetMember, newState); stickyRoleService.setStickiness(targetMember, newState);
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
} else { } else {
String userIdStr = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, String.class); stickyRoleService.setStickiness(targetUser, event.getGuild(), newState);
Long userId = Long.parseLong(userIdStr);
return userService.retrieveUserForId(userId).thenCompose(user -> {
self.callService(event, user, newState);
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event);
}).thenApply(interactionHook -> CommandResult.fromSuccess());
} }
} return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
@Transactional
public void callService(SlashCommandInteractionEvent event, User user, Boolean newState) {
stickyRoleService.setStickiness(user, event.getGuild(), newState);
} }
@Override @Override

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>sticky-roles</artifactId> <artifactId>sticky-roles</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<artifactId>sticky-roles-int</artifactId> <artifactId>sticky-roles-int</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>suggestion</artifactId> <artifactId>suggestion</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>suggestion</artifactId> <artifactId>suggestion</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>twitch</artifactId> <artifactId>twitch</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>twitch</artifactId> <artifactId>twitch</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility</artifactId> <artifactId>utility</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility</artifactId> <artifactId>utility</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>voice-channel-context</artifactId> <artifactId>voice-channel-context</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>voice-channel-context</artifactId> <artifactId>voice-channel-context</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>webservices</artifactId> <artifactId>webservices</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>webservices</artifactId> <artifactId>webservices</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto</groupId> <groupId>dev.sheldan.abstracto</groupId>
<artifactId>abstracto-application</artifactId> <artifactId>abstracto-application</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.core</groupId> <groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@@ -14,14 +14,18 @@ import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition; import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.interaction.InteractionService; import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.template.commands.FeatureSwitchModel; import dev.sheldan.abstracto.core.models.template.commands.FeatureSwitchModel;
import dev.sheldan.abstracto.core.service.FeatureConfigService; import dev.sheldan.abstracto.core.service.FeatureConfigService;
import dev.sheldan.abstracto.core.service.FeatureFlagService; import dev.sheldan.abstracto.core.service.FeatureFlagService;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService; import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService; import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend; import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService; import dev.sheldan.abstracto.core.templating.service.TemplateService;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -54,6 +58,12 @@ public class DisableFeature extends AbstractConditionableCommand {
@Autowired @Autowired
private InteractionService interactionService; private InteractionService interactionService;
@Autowired
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
@Autowired
private FeatureFlagManagementService featureFlagManagementService;
private static final String DISABLE_FEATURE_DEPENDENCIES_RESPONSE_TEMPLATE_KEY = "disableFeature_feature_dependencies_response"; private static final String DISABLE_FEATURE_DEPENDENCIES_RESPONSE_TEMPLATE_KEY = "disableFeature_feature_dependencies_response";
private static final String DISABLE_FEATURE_RESPONSE_TEMPLATE_KEY = "disableFeature_response"; private static final String DISABLE_FEATURE_RESPONSE_TEMPLATE_KEY = "disableFeature_response";
private static final String FEATURE_NAME_PARAMETER = "featureName"; private static final String FEATURE_NAME_PARAMETER = "featureName";
@@ -99,6 +109,21 @@ public class DisableFeature extends AbstractConditionableCommand {
return featureDependencies; return featureDependencies;
} }
@Override
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), FEATURE_NAME_PARAMETER)) {
String input = event.getFocusedOption().getValue().toLowerCase();
AServer server = serverManagementService.loadServer(event.getGuild());
return featureFlagManagementService.getFeatureFlagsOfServer(server)
.stream()
.filter(AFeatureFlag::isEnabled)
.map(aFeatureFlag -> aFeatureFlag.getFeature().getKey().toLowerCase())
.filter(featureName -> featureName.toLowerCase().startsWith(input))
.toList();
}
return new ArrayList<>();
}
@Override @Override
public CommandConfiguration getConfiguration() { public CommandConfiguration getConfiguration() {
Parameter featureName = Parameter Parameter featureName = Parameter
@@ -106,6 +131,7 @@ public class DisableFeature extends AbstractConditionableCommand {
.name(FEATURE_NAME_PARAMETER) .name(FEATURE_NAME_PARAMETER)
.templated(true) .templated(true)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.build(); .build();
List<Parameter> parameters = Arrays.asList(featureName); List<Parameter> parameters = Arrays.asList(featureName);

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.core.commands.config.features; package dev.sheldan.abstracto.core.commands.config.features;
import dev.sheldan.abstracto.core.command.service.management.FeatureManagementService;
import dev.sheldan.abstracto.core.interaction.slash.CoreSlashCommandNames; import dev.sheldan.abstracto.core.interaction.slash.CoreSlashCommandNames;
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand; import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
import dev.sheldan.abstracto.core.command.config.CommandConfiguration; import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
@@ -13,11 +14,19 @@ import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.FeatureMode; import dev.sheldan.abstracto.core.config.FeatureMode;
import dev.sheldan.abstracto.core.interaction.InteractionService; import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
import dev.sheldan.abstracto.core.models.database.AFeatureMode;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.FeatureConfigService; import dev.sheldan.abstracto.core.service.FeatureConfigService;
import dev.sheldan.abstracto.core.service.FeatureModeService; import dev.sheldan.abstracto.core.service.FeatureModeService;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService; import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
import dev.sheldan.abstracto.core.service.management.FeatureModeManagementService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService; import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import java.util.ArrayList;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -44,6 +53,18 @@ public class DisableMode extends AbstractConditionableCommand {
@Autowired @Autowired
private InteractionService interactionService; private InteractionService interactionService;
@Autowired
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
@Autowired
private FeatureFlagManagementService featureFlagManagementService;
@Autowired
private FeatureModeManagementService featureModeManagementService;
@Autowired
private FeatureManagementService featureManagementService;
private static final String DISABLE_MODE_RESPONSE_KEY = "disableMode_response"; private static final String DISABLE_MODE_RESPONSE_KEY = "disableMode_response";
private static final String FEATURE_PARAMETER = "feature"; private static final String FEATURE_PARAMETER = "feature";
private static final String MODE_PARAMETER = "mode"; private static final String MODE_PARAMETER = "mode";
@@ -61,12 +82,41 @@ public class DisableMode extends AbstractConditionableCommand {
.thenApply(interactionHook -> CommandResult.fromSuccess()); .thenApply(interactionHook -> CommandResult.fromSuccess());
} }
@Override
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
String input = event.getFocusedOption().getValue().toLowerCase();
AServer server = serverManagementService.loadServer(event.getGuild());
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), FEATURE_PARAMETER)) {
return featureFlagManagementService.getFeatureFlagsOfServer(server)
.stream()
.filter(AFeatureFlag::isEnabled)
.map(aFeatureFlag -> aFeatureFlag.getFeature().getKey().toLowerCase())
.filter(featureName -> featureName.toLowerCase().startsWith(input))
.toList();
} else if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), MODE_PARAMETER)) {
String featureName = slashCommandParameterService.getCommandOption(FEATURE_PARAMETER, event, String.class);
if(featureName.isBlank()) {
return new ArrayList<>();
}
FeatureDefinition featureDefinition = featureConfigService.getFeatureEnum(featureName);
AFeature feature = featureManagementService.getFeature(featureDefinition.getKey());
List<AFeatureMode> modes = featureModeManagementService.getFeatureModesOfFeatureInServer(server, feature);
return modes
.stream()
.map(mode -> mode.getFeatureMode().toLowerCase())
.filter(string -> string.startsWith(input))
.toList();
}
return new ArrayList<>();
}
@Override @Override
public CommandConfiguration getConfiguration() { public CommandConfiguration getConfiguration() {
Parameter featureName = Parameter Parameter featureName = Parameter
.builder() .builder()
.name(FEATURE_PARAMETER) .name(FEATURE_PARAMETER)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.templated(true) .templated(true)
.build(); .build();
@@ -74,6 +124,7 @@ public class DisableMode extends AbstractConditionableCommand {
.builder() .builder()
.name(MODE_PARAMETER) .name(MODE_PARAMETER)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.templated(true) .templated(true)
.build(); .build();
List<Parameter> parameters = Arrays.asList(featureName, mode); List<Parameter> parameters = Arrays.asList(featureName, mode);

View File

@@ -14,6 +14,7 @@ import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition; import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.interaction.InteractionService; import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
import dev.sheldan.abstracto.core.models.FeatureValidationResult; import dev.sheldan.abstracto.core.models.FeatureValidationResult;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.template.commands.FeatureSwitchModel; import dev.sheldan.abstracto.core.models.template.commands.FeatureSwitchModel;
@@ -24,6 +25,7 @@ import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend; import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService; import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -56,6 +58,9 @@ public class EnableFeature extends AbstractConditionableCommand {
@Autowired @Autowired
private InteractionService interactionService; private InteractionService interactionService;
@Autowired
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
private static final String ENABLE_FEATURE_DEPENDENCIES_RESPONSE_TEMPLATE_KEY = "enableFeature_feature_dependencies_response"; private static final String ENABLE_FEATURE_DEPENDENCIES_RESPONSE_TEMPLATE_KEY = "enableFeature_feature_dependencies_response";
private static final String ENABLE_FEATURE_RESPONSE_TEMPLATE_KEY = "enableFeature_response"; private static final String ENABLE_FEATURE_RESPONSE_TEMPLATE_KEY = "enableFeature_response";
private static final String FEATURE_NAME_PARAMETER = "featureName"; private static final String FEATURE_NAME_PARAMETER = "featureName";
@@ -114,12 +119,26 @@ public class EnableFeature extends AbstractConditionableCommand {
return result; return result;
} }
@Override
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), FEATURE_NAME_PARAMETER)) {
String input = event.getFocusedOption().getValue().toLowerCase();
return featureConfigService.getAllFeatures()
.stream()
.map(String::toLowerCase)
.filter(lowerCase -> lowerCase.startsWith(input))
.toList();
}
return new ArrayList<>();
}
@Override @Override
public CommandConfiguration getConfiguration() { public CommandConfiguration getConfiguration() {
Parameter featureName = Parameter Parameter featureName = Parameter
.builder() .builder()
.name(FEATURE_NAME_PARAMETER) .name(FEATURE_NAME_PARAMETER)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.templated(true) .templated(true)
.build(); .build();
List<Parameter> parameters = Arrays.asList(featureName); List<Parameter> parameters = Arrays.asList(featureName);

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.core.commands.config.features; package dev.sheldan.abstracto.core.commands.config.features;
import dev.sheldan.abstracto.core.command.service.management.FeatureManagementService;
import dev.sheldan.abstracto.core.interaction.slash.CoreSlashCommandNames; import dev.sheldan.abstracto.core.interaction.slash.CoreSlashCommandNames;
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand; import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
import dev.sheldan.abstracto.core.command.config.CommandConfiguration; import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
@@ -13,11 +14,19 @@ import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.FeatureMode; import dev.sheldan.abstracto.core.config.FeatureMode;
import dev.sheldan.abstracto.core.interaction.InteractionService; import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
import dev.sheldan.abstracto.core.models.database.AFeatureMode;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.FeatureConfigService; import dev.sheldan.abstracto.core.service.FeatureConfigService;
import dev.sheldan.abstracto.core.service.FeatureModeService; import dev.sheldan.abstracto.core.service.FeatureModeService;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService; import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
import dev.sheldan.abstracto.core.service.management.FeatureModeManagementService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService; import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import java.util.ArrayList;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -44,6 +53,18 @@ public class EnableMode extends AbstractConditionableCommand {
@Autowired @Autowired
private ServerManagementService serverManagementService; private ServerManagementService serverManagementService;
@Autowired
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
@Autowired
private FeatureFlagManagementService featureFlagManagementService;
@Autowired
private FeatureModeManagementService featureModeManagementService;
@Autowired
private FeatureManagementService featureManagementService;
private static final String ENABLE_MODE_RESPONSE_KEY = "enableMode_response"; private static final String ENABLE_MODE_RESPONSE_KEY = "enableMode_response";
private static final String FEATURE_PARAMETER = "feature"; private static final String FEATURE_PARAMETER = "feature";
private static final String MODE_PARAMETER = "mode"; private static final String MODE_PARAMETER = "mode";
@@ -61,16 +82,49 @@ public class EnableMode extends AbstractConditionableCommand {
.thenApply(interactionHook -> CommandResult.fromSuccess()); .thenApply(interactionHook -> CommandResult.fromSuccess());
} }
@Override
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
AServer server = serverManagementService.loadServer(event.getGuild());
String input = event.getFocusedOption().getValue().toLowerCase();
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), FEATURE_PARAMETER)) {
return featureFlagManagementService.getFeatureFlagsOfServer(server)
.stream()
.filter(AFeatureFlag::isEnabled)
.map(aFeatureFlag -> aFeatureFlag.getFeature().getKey().toLowerCase())
.filter(featureName -> featureName.toLowerCase().startsWith(input))
.toList();
} else if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), MODE_PARAMETER)) {
String featureName = slashCommandParameterService.getCommandOption(FEATURE_PARAMETER, event, String.class);
if(featureName.isBlank()) {
return new ArrayList<>();
}
FeatureDefinition featureDefinition = featureConfigService.getFeatureEnum(featureName);
AFeature feature = featureManagementService.getFeature(featureDefinition.getKey());
List<AFeatureMode> modes = featureModeManagementService.getFeatureModesOfFeatureInServer(server, feature);
return modes
.stream()
.map(mode -> mode.getFeatureMode().toLowerCase())
.filter(string -> string.startsWith(input))
.toList();
}
return new ArrayList<>();
}
@Override @Override
public CommandConfiguration getConfiguration() { public CommandConfiguration getConfiguration() {
Parameter featureName = Parameter Parameter featureName = Parameter
.builder() .builder()
.name(FEATURE_PARAMETER) .name(FEATURE_PARAMETER)
.type(String.class) .type(String.class)
.templated(true).build(); .supportsAutoComplete(true)
.templated(true)
.build();
Parameter mode = Parameter Parameter mode = Parameter
.builder().name(MODE_PARAMETER) .builder()
.name(MODE_PARAMETER)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.templated(true) .templated(true)
.build(); .build();

View File

@@ -13,14 +13,19 @@ import dev.sheldan.abstracto.core.commands.config.ConfigModuleDefinition;
import dev.sheldan.abstracto.core.config.FeatureDefinition; import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.interaction.InteractionService; import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels; import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
import dev.sheldan.abstracto.core.models.database.AFeature; import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.template.commands.FeatureModeDisplay; import dev.sheldan.abstracto.core.models.template.commands.FeatureModeDisplay;
import dev.sheldan.abstracto.core.models.template.commands.FeatureModesModel; import dev.sheldan.abstracto.core.models.template.commands.FeatureModesModel;
import dev.sheldan.abstracto.core.service.FeatureConfigService; import dev.sheldan.abstracto.core.service.FeatureConfigService;
import dev.sheldan.abstracto.core.service.FeatureModeService; import dev.sheldan.abstracto.core.service.FeatureModeService;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService; import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.service.management.FeatureFlagManagementService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService; import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import java.util.ArrayList;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -53,6 +58,12 @@ public class FeatureModes extends AbstractConditionableCommand {
@Autowired @Autowired
private SlashCommandParameterService slashCommandParameterService; private SlashCommandParameterService slashCommandParameterService;
@Autowired
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
@Autowired
private FeatureFlagManagementService featureFlagManagementService;
@Override @Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) { public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
List<FeatureModeDisplay> featureModes; List<FeatureModeDisplay> featureModes;
@@ -73,12 +84,28 @@ public class FeatureModes extends AbstractConditionableCommand {
.thenApply(interactionHook -> CommandResult.fromSuccess()); .thenApply(interactionHook -> CommandResult.fromSuccess());
} }
@Override
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), FEATURE_PARAMETER)) {
String input = event.getFocusedOption().getValue().toLowerCase();
AServer server = serverManagementService.loadServer(event.getGuild());
return featureFlagManagementService.getFeatureFlagsOfServer(server)
.stream()
.filter(AFeatureFlag::isEnabled)
.map(aFeatureFlag -> aFeatureFlag.getFeature().getKey().toLowerCase())
.filter(featureName -> featureName.toLowerCase().startsWith(input))
.toList();
}
return new ArrayList<>();
}
@Override @Override
public CommandConfiguration getConfiguration() { public CommandConfiguration getConfiguration() {
Parameter featureName = Parameter Parameter featureName = Parameter
.builder() .builder()
.name(FEATURE_PARAMETER) .name(FEATURE_PARAMETER)
.type(String.class) .type(String.class)
.supportsAutoComplete(true)
.optional(true) .optional(true)
.templated(true) .templated(true)
.build(); .build();

View File

@@ -16,7 +16,7 @@ public class UserSlashCommandParameterProvider implements SlashCommandParameterP
return SlashCommandOptionTypeMapping return SlashCommandOptionTypeMapping
.builder() .builder()
.type(User.class) .type(User.class)
.optionTypes(Arrays.asList(OptionType.USER, OptionType.STRING)) .optionTypes(Arrays.asList(OptionType.USER))
.strictTypes(List.of(OptionType.USER)) .strictTypes(List.of(OptionType.USER))
.build(); .build();
} }

View File

@@ -13,6 +13,7 @@ public class ButtonConfig {
private String id; private String id;
private String url; private String url;
private Boolean disabled; private Boolean disabled;
private Integer uniqueId;
private String emoteMarkdown; private String emoteMarkdown;
private ButtonStyleConfig buttonStyle; private ButtonStyleConfig buttonStyle;
private String buttonPayload; private String buttonPayload;

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
import java.awt.Color;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Builder
@Getter
@Setter
public class ContainerColor {
private Integer r;
private Integer g;
private Integer b;
public Color toColor() {
return new Color(r, g, b);
}
}

View File

@@ -8,6 +8,10 @@ import lombok.experimental.SuperBuilder;
@Getter @Getter
public class ContainerConfig implements ComponentConfig { public class ContainerConfig implements ComponentConfig {
private List<ComponentConfig> components; private List<ComponentConfig> components;
private ContainerColor color;
private Integer uniqueId;
private Boolean spoiler;
private Boolean disabled;
@Override @Override
public ComponentTypeConfig getType() { public ComponentTypeConfig getType() {
return ComponentTypeConfig.CONTAINER; return ComponentTypeConfig.CONTAINER;

View File

@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
@Getter @Getter
public class MediaGalleryConfig implements ComponentConfig { public class MediaGalleryConfig implements ComponentConfig {
private List<ImageConfig> images; private List<ImageConfig> images;
private Integer uniqueId;
@Override @Override
public ComponentTypeConfig getType() { public ComponentTypeConfig getType() {
return ComponentTypeConfig.MEDIA_GALLERY; return ComponentTypeConfig.MEDIA_GALLERY;

View File

@@ -9,5 +9,7 @@ import lombok.experimental.SuperBuilder;
public class SectionConfig { public class SectionConfig {
protected SectionAccessoryConfig accessory; protected SectionAccessoryConfig accessory;
protected List<SectionComponentConfig> components; protected List<SectionComponentConfig> components;
private Boolean disabled;
private Integer uniqueId;
} }

View File

@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
public class SeparatorConfig implements ComponentConfig { public class SeparatorConfig implements ComponentConfig {
private Boolean divider; private Boolean divider;
private Spacing spacing; private Spacing spacing;
private Integer uniqueId;
@Override @Override
public ComponentTypeConfig getType() { public ComponentTypeConfig getType() {
return ComponentTypeConfig.SEPARATOR; return ComponentTypeConfig.SEPARATOR;

View File

@@ -351,7 +351,14 @@ public class TemplateServiceBean implements TemplateService {
} }
} }
if(accessory != null) { if(accessory != null) {
return Section.of(accessory, sectionComponents); Section section = Section.of(accessory, sectionComponents);
if(sectionConfig.getDisabled() != null) {
section = section.withDisabled(sectionConfig.getDisabled());
}
if(sectionConfig.getUniqueId() != null) {
section = section.withUniqueId(sectionConfig.getUniqueId());
}
return section;
} }
} }
} else if(componentConfig instanceof TopLevelFileConfig fileConfig) { } else if(componentConfig instanceof TopLevelFileConfig fileConfig) {
@@ -380,11 +387,19 @@ public class TemplateServiceBean implements TemplateService {
} }
galleryItems.add(item); galleryItems.add(item);
}); });
return MediaGallery.of(galleryItems); MediaGallery gallery = MediaGallery.of(galleryItems);
if(mediaGalleryConfig.getUniqueId() != null) {
gallery = gallery.withUniqueId(mediaGalleryConfig.getUniqueId());
}
return gallery;
} }
} else if(componentConfig instanceof TopLevelSeperatorConfig seperatorConfig) { } else if(componentConfig instanceof TopLevelSeperatorConfig seperatorConfig) {
return Separator.create(seperatorConfig.getDivider(), Separator separator = Separator.create(seperatorConfig.getDivider(),
Spacing.toSpacing(seperatorConfig.getSpacing())); Spacing.toSpacing(seperatorConfig.getSpacing()));
if(seperatorConfig.getUniqueId() != null) {
separator = separator.withUniqueId(seperatorConfig.getUniqueId());
}
return separator;
} else if(componentConfig instanceof TopLevelContainerConfig topLevelContainerConfig) { } else if(componentConfig instanceof TopLevelContainerConfig topLevelContainerConfig) {
List<ContainerChildComponent> childComponents = new ArrayList<>(); List<ContainerChildComponent> childComponents = new ArrayList<>();
for (ComponentConfig containerComponent : topLevelContainerConfig.getComponents()) { for (ComponentConfig containerComponent : topLevelContainerConfig.getComponents()) {
@@ -393,7 +408,20 @@ public class TemplateServiceBean implements TemplateService {
childComponents.add((ContainerChildComponent) createdComponent); childComponents.add((ContainerChildComponent) createdComponent);
} }
} }
return Container.of(childComponents); Container container = Container.of(childComponents);
if(topLevelContainerConfig.getColor() != null) {
container = container.withAccentColor(topLevelContainerConfig.getColor().toColor());
}
if(topLevelContainerConfig.getUniqueId() != null) {
container = container.withUniqueId(topLevelContainerConfig.getUniqueId());
}
if(topLevelContainerConfig.getDisabled() != null) {
container = container.withDisabled(topLevelContainerConfig.getDisabled());
}
if(topLevelContainerConfig.getSpoiler() != null) {
container = container.withSpoiler(topLevelContainerConfig.getSpoiler());
}
return container;
} }
return null; return null;
} }
@@ -545,6 +573,9 @@ public class TemplateServiceBean implements TemplateService {
if (buttonConfig.getDisabled() != null) { if (buttonConfig.getDisabled() != null) {
createdButton = createdButton.withDisabled(buttonConfig.getDisabled()); createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
} }
if(buttonConfig.getUniqueId() != null) {
createdButton = createdButton.withUniqueId(buttonConfig.getUniqueId());
}
return createdButton; return createdButton;
} }

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.core</groupId> <groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<groupId>dev.sheldan.abstracto.core</groupId> <groupId>dev.sheldan.abstracto.core</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<groupId>dev.sheldan.abstracto.core</groupId> <groupId>dev.sheldan.abstracto.core</groupId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto</groupId> <groupId>dev.sheldan.abstracto</groupId>
<artifactId>abstracto-application</artifactId> <artifactId>abstracto-application</artifactId>
<version>1.6.9-SNAPSHOT</version> <version>1.6.12-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Some files were not shown because too many files have changed in this diff Show More