mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-13 04:05:17 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff3e3d85ba | ||
|
|
46bf4fbc42 | ||
|
|
97ac25dbb6 | ||
|
|
ef4bdb2ab2 | ||
|
|
433fdb7068 | ||
|
|
e59b6269e1 | ||
|
|
8077501584 | ||
|
|
cb9ab8f542 | ||
|
|
f513f8890b | ||
|
|
6f02834b75 | ||
|
|
75456b45c9 | ||
|
|
92e581305e | ||
|
|
bd8b57e977 | ||
|
|
e5fc411dc2 | ||
|
|
9d9fdef42e | ||
|
|
4a3d43b1b0 | ||
|
|
15d41c58ef | ||
|
|
ad863af5d6 | ||
|
|
f3dae2f6a3 | ||
|
|
9f9c0612eb | ||
|
|
db73071a71 | ||
|
|
d7125fbf25 | ||
|
|
fd3bf41406 | ||
|
|
d1abe194ec | ||
|
|
79477923c6 | ||
|
|
be9ffa3045 | ||
|
|
e29ceb9243 | ||
|
|
70acf46cfd | ||
|
|
022603ae3b | ||
|
|
264082d63d |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||
VERSION=1.6.4
|
||||
VERSION=1.6.11
|
||||
@@ -11,7 +11,7 @@ This repository does not provide the full functionality in order to start a disc
|
||||
|
||||
|
||||
## Technologies
|
||||
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.0.0-beta.21
|
||||
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.4.0
|
||||
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including dependency injection and more)
|
||||
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
|
||||
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.
|
||||
@@ -30,4 +30,4 @@ If you want to view the documentation to an earlier released version you need to
|
||||
If you find any issue, feel free to create a GitHub issue.
|
||||
|
||||
## License
|
||||
This project is licensed under the MIT license.
|
||||
This project is licensed under the MIT license.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
|
||||
import net.dv8tion.jda.api.components.buttons.ButtonStyle;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>assignable-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ public class Choose extends AbstractConditionableCommand {
|
||||
String choice = entertainmentService.takeChoice(choices, commandContext.getAuthor());
|
||||
ChooseResponseModel responseModel = ChooseResponseModel
|
||||
.builder()
|
||||
.choices(choices)
|
||||
.chosenValue(choice)
|
||||
.build();
|
||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
|
||||
@@ -70,6 +71,7 @@ public class Choose extends AbstractConditionableCommand {
|
||||
String choice = entertainmentService.takeChoice(choices, event.getMember());
|
||||
ChooseResponseModel responseModel = ChooseResponseModel
|
||||
.builder()
|
||||
.choices(choices)
|
||||
.chosenValue(choice)
|
||||
.build();
|
||||
return interactionService.replyEmbed(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, event)
|
||||
|
||||
@@ -56,6 +56,7 @@ public class EightBall extends AbstractConditionableCommand {
|
||||
String chosenKey = entertainmentService.getEightBallValue(text);
|
||||
EightBallResponseModel responseModel = EightBallResponseModel
|
||||
.builder()
|
||||
.input(text)
|
||||
.chosenKey(chosenKey)
|
||||
.build();
|
||||
return templateService.renderEmbedTemplate(EIGHT_BALL_RESPONSE_TEMPLATE_KEY, responseModel, serverId);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.entertainment.model.command;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -9,4 +10,5 @@ import lombok.Setter;
|
||||
@Builder
|
||||
public class ChooseResponseModel {
|
||||
private String chosenValue;
|
||||
private List<String> choices;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ import lombok.Setter;
|
||||
@Builder
|
||||
public class EightBallResponseModel {
|
||||
private String chosenKey;
|
||||
private String input;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>giveaway</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway-impl</artifactId>
|
||||
|
||||
@@ -155,7 +155,7 @@ public class GiveawayServiceBean implements GiveawayService {
|
||||
Long giveawayId = giveaway.getGiveawayId().getId();
|
||||
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());
|
||||
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), messageChannel, giveaway.getMessageId())
|
||||
return channelService.editMessageInAChannelFuture(messageToSend, messageChannel, giveaway.getMessageId())
|
||||
.thenAccept(message -> {
|
||||
self.persistAddedParticipant(member, giveawayId);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>giveaway</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway-int</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>image-generation</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation-impl</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>image-generation</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation-int</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation-int</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import dev.sheldan.abstracto.core.interaction.button.ButtonConfigModel;
|
||||
import dev.sheldan.abstracto.core.interaction.ComponentPayloadManagementService;
|
||||
import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureDefinition;
|
||||
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.MessageEmbeddedModel;
|
||||
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.templating.model.MessageToSend;
|
||||
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.linkembed.model.MessageEmbedLink;
|
||||
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.channel.middleman.GuildMessageChannel;
|
||||
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.Value;
|
||||
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);
|
||||
|
||||
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";
|
||||
|
||||
@Autowired
|
||||
@@ -78,9 +80,6 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
@Autowired
|
||||
private ReactionService reactionService;
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
private ComponentService componentServiceBean;
|
||||
|
||||
@@ -160,15 +159,21 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
log.info("Cleaning up {} embedded embeddedMessages", embeddedMessages.size());
|
||||
List<ServerChannelMessage> reactionChannelMessages = embeddedMessages.stream()
|
||||
.filter(embeddedMessage -> embeddedMessage.getDeletionComponentId() == null)
|
||||
.map(this::convertEmbedMessageToServerChannelMessage)
|
||||
.collect(Collectors.toList());
|
||||
List<Pair<ServerChannelMessage, ServerChannelMessage>> embeddingMessages = embeddedMessages.stream()
|
||||
.map(embeddedMessage -> Pair.of(ServerChannelMessage
|
||||
.builder()
|
||||
.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
|
||||
.stream()
|
||||
.map(EmbeddedMessage::getEmbeddingMessageId)
|
||||
@@ -179,67 +184,26 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<CompletableFuture<Message>> reactionMessageFutures = messageService.retrieveMessages(reactionChannelMessages);
|
||||
List<CompletableFuture<Message>> buttonMessageFutures = messageService.retrieveMessages(buttonChannelMessages);
|
||||
CompletableFutureList<Message> reactionFutureList = new CompletableFutureList<>(reactionMessageFutures);
|
||||
CompletableFutureList<Message> buttonFutureList = new CompletableFutureList<>(buttonMessageFutures);
|
||||
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
|
||||
List<CompletableFuture<Message>> editList = embeddingMessages.stream().map(messagePair -> {
|
||||
ServerChannelMessage embeddingMessage = messagePair.getLeft();
|
||||
ServerChannelMessage embeddedMessage = messagePair.getRight();
|
||||
MessageEmbedCleanupReplacementModel model = MessageEmbedCleanupReplacementModel
|
||||
.builder()
|
||||
.serverId(embeddedMessage.getEmbeddingServer().getId())
|
||||
.channelId(embeddedMessage.getEmbeddingChannel().getId())
|
||||
.messageId(embeddedMessage.getEmbeddingMessageId())
|
||||
.message(embeddedMessage)
|
||||
.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
|
||||
public void deleteEmbeddedMessages(List<Long> embeddedMessagesToDelete, List<String> componentPayloadsToDelete) {
|
||||
@@ -357,7 +321,9 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
|
||||
private Boolean shouldMentionReferencedAuthor(Message message) {
|
||||
if(message.getReferencedMessage() != null) {
|
||||
return message.getMentions().getMentions(Message.MentionType.USER).contains(message.getReferencedMessage().getAuthor());
|
||||
return message.getMentions().getMentions(Message.MentionType.USER)
|
||||
.stream()
|
||||
.anyMatch(user -> message.getReferencedMessage().getAuthor().getIdLong() == user.getIdLong());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
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.stereotype.Component;
|
||||
|
||||
@@ -76,16 +75,15 @@ public class Ban extends AbstractConditionableCommand {
|
||||
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()
|
||||
.thenCompose((hook) -> self.banMember(event, member, reason, duration, hook))
|
||||
.thenApply(commandResult -> CommandResult.fromSuccess());
|
||||
} else {
|
||||
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class);
|
||||
Long userId = Long.parseLong(userIdStr);
|
||||
User user = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, User.class);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
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.stereotype.Component;
|
||||
|
||||
@@ -86,16 +85,15 @@ public class Infractions extends AbstractConditionableCommand {
|
||||
public CompletableFuture<CommandResult> showInfractions(InteractionHook hook, SlashCommandInteractionEvent event) {
|
||||
List<Infraction> infractions;
|
||||
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)) {
|
||||
throw new EntityGuildMismatchException();
|
||||
}
|
||||
infractions = infractionManagementService.getInfractionsForUser(userInServerManagementService.loadOrCreateUser(member));
|
||||
} else if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.STRING)){
|
||||
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class);
|
||||
Long userId = Long.parseLong(userIdStr);
|
||||
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), userId);
|
||||
} else if(user != null){
|
||||
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), user.getIdLong());
|
||||
infractions = infractionManagementService.getInfractionsForUser(userInServer);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -223,6 +223,9 @@ public class RemindServiceBean implements ReminderService {
|
||||
.builder()
|
||||
.reminderParticipants(participantsDisplays)
|
||||
.reminderDisplay(reminderDisplay)
|
||||
.serverId(reminder.getServer().getId())
|
||||
.channelId(reminder.getChannel().getId())
|
||||
.messageId(reminder.getMessageId())
|
||||
.userDisplay(UserDisplay.fromUser(member.getUser()))
|
||||
.duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate()))
|
||||
.build();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -138,8 +138,12 @@ public abstract class StarboardListener {
|
||||
|
||||
protected void updateStarboardPost(CachedMessage message, AUserInAServer userReacting, boolean adding, StarboardPost starboardPost, List<AUserInAServer> userExceptAuthor) {
|
||||
starboardPost.setIgnored(false);
|
||||
// TODO handle futures correctly
|
||||
starboardService.updateStarboardPost(starboardPost, message, userExceptAuthor);
|
||||
starboardService.updateStarboardPost(starboardPost, message, userExceptAuthor)
|
||||
.thenAccept(unused -> log.info("Updated starboard post."))
|
||||
.exceptionally(throwable -> {
|
||||
log.error("Failed to update starboard post.", throwable);
|
||||
return null;
|
||||
});
|
||||
if(adding) {
|
||||
log.debug("Adding reactor {} from message {}", userReacting.getUserReference().getId(), message.getMessageId());
|
||||
starboardPostReactorManagementService.addReactor(starboardPost, userReacting);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>sticky-roles</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sticky-roles-impl</artifactId>
|
||||
|
||||
@@ -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.SlashCommandPrivilegeLevels;
|
||||
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.StickyRolesSlashCommandNames;
|
||||
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.User;
|
||||
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.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -47,34 +44,18 @@ public class ToggleStickinessManagement extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private StickyRoleService stickyRoleService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private ToggleStickinessManagement self;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||
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);
|
||||
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
|
||||
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||
} else {
|
||||
String userIdStr = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, String.class);
|
||||
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());
|
||||
stickyRoleService.setStickiness(targetUser, event.getGuild(), newState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void callService(SlashCommandInteractionEvent event, User user, Boolean newState) {
|
||||
stickyRoleService.setStickiness(user, event.getGuild(), newState);
|
||||
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
|
||||
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>sticky-roles</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sticky-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>twitch</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>twitch</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
|
||||
@Override
|
||||
public YoutubeVideo searchOneVideoForQuery(String query) {
|
||||
try {
|
||||
YouTube.Search.List search = youTube.search().list("id,snippet");
|
||||
YouTube.Search.List search = youTube.search().list("id");
|
||||
search.setQ(query);
|
||||
search.setType("video");
|
||||
search.setMaxResults(1L);
|
||||
@@ -35,6 +35,9 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
|
||||
if(items.isEmpty()) {
|
||||
throw new YoutubeVideoNotFoundException();
|
||||
}
|
||||
if(items.stream().noneMatch(searchResult -> searchResult.getId().get("kind").equals("youtube#video"))) {
|
||||
throw new YoutubeVideoNotFoundException();
|
||||
}
|
||||
return youtubeVideoService.getVideoInfo(items.get(0).getId().getVideoId());
|
||||
} catch (IOException e) {
|
||||
throw new YoutubeAPIException(e);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<version>1.6.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
@@ -84,7 +84,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<groupId>io.github.freya022</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -131,6 +131,11 @@
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.danilopianini</groupId>
|
||||
<artifactId>gson-extras</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
||||
@@ -14,14 +14,18 @@ import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
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.template.commands.FeatureSwitchModel;
|
||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
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.templating.model.MessageToSend;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -54,6 +58,12 @@ public class DisableFeature extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
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_RESPONSE_TEMPLATE_KEY = "disableFeature_response";
|
||||
private static final String FEATURE_NAME_PARAMETER = "featureName";
|
||||
@@ -99,6 +109,21 @@ public class DisableFeature extends AbstractConditionableCommand {
|
||||
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
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter featureName = Parameter
|
||||
@@ -106,6 +131,7 @@ public class DisableFeature extends AbstractConditionableCommand {
|
||||
.name(FEATURE_NAME_PARAMETER)
|
||||
.templated(true)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.build();
|
||||
List<Parameter> parameters = Arrays.asList(featureName);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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.command.condition.AbstractConditionableCommand;
|
||||
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.interaction.InteractionService;
|
||||
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.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
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 java.util.ArrayList;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -44,6 +53,18 @@ public class DisableMode extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
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 FEATURE_PARAMETER = "feature";
|
||||
private static final String MODE_PARAMETER = "mode";
|
||||
@@ -61,12 +82,41 @@ public class DisableMode extends AbstractConditionableCommand {
|
||||
.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
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter featureName = Parameter
|
||||
.builder()
|
||||
.name(FEATURE_PARAMETER)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
|
||||
@@ -74,6 +124,7 @@ public class DisableMode extends AbstractConditionableCommand {
|
||||
.builder()
|
||||
.name(MODE_PARAMETER)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
List<Parameter> parameters = Arrays.asList(featureName, mode);
|
||||
|
||||
@@ -14,6 +14,7 @@ import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
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.database.AServer;
|
||||
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.service.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -56,6 +58,9 @@ public class EnableFeature extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
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_RESPONSE_TEMPLATE_KEY = "enableFeature_response";
|
||||
private static final String FEATURE_NAME_PARAMETER = "featureName";
|
||||
@@ -114,12 +119,26 @@ public class EnableFeature extends AbstractConditionableCommand {
|
||||
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
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter featureName = Parameter
|
||||
.builder()
|
||||
.name(FEATURE_NAME_PARAMETER)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
List<Parameter> parameters = Arrays.asList(featureName);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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.command.condition.AbstractConditionableCommand;
|
||||
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.interaction.InteractionService;
|
||||
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.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
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 java.util.ArrayList;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -44,6 +53,18 @@ public class EnableMode extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
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 FEATURE_PARAMETER = "feature";
|
||||
private static final String MODE_PARAMETER = "mode";
|
||||
@@ -61,16 +82,49 @@ public class EnableMode extends AbstractConditionableCommand {
|
||||
.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
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter featureName = Parameter
|
||||
.builder()
|
||||
.name(FEATURE_PARAMETER)
|
||||
.type(String.class)
|
||||
.templated(true).build();
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
|
||||
Parameter mode = Parameter
|
||||
.builder().name(MODE_PARAMETER)
|
||||
.builder()
|
||||
.name(MODE_PARAMETER)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -13,14 +13,19 @@ import dev.sheldan.abstracto.core.commands.config.ConfigModuleDefinition;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
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.AServer;
|
||||
import dev.sheldan.abstracto.core.models.template.commands.FeatureModeDisplay;
|
||||
import dev.sheldan.abstracto.core.models.template.commands.FeatureModesModel;
|
||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
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 java.util.ArrayList;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -53,6 +58,12 @@ public class FeatureModes extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private SlashCommandParameterService slashCommandParameterService;
|
||||
|
||||
@Autowired
|
||||
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
|
||||
|
||||
@Autowired
|
||||
private FeatureFlagManagementService featureFlagManagementService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||
List<FeatureModeDisplay> featureModes;
|
||||
@@ -73,12 +84,28 @@ public class FeatureModes extends AbstractConditionableCommand {
|
||||
.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
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter featureName = Parameter
|
||||
.builder()
|
||||
.name(FEATURE_PARAMETER)
|
||||
.type(String.class)
|
||||
.supportsAutoComplete(true)
|
||||
.optional(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
|
||||
@@ -3,9 +3,25 @@ package dev.sheldan.abstracto.core.config;
|
||||
import ch.qos.logback.core.net.ssl.SecureRandomFactoryBean;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
|
||||
import dev.sheldan.abstracto.core.logging.OkHttpLogger;
|
||||
import dev.sheldan.abstracto.core.metric.OkHttpMetrics;
|
||||
import dev.sheldan.abstracto.core.service.BotService;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ActionRowButtonConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ActionRowItemConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ComponentConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionAccessoryConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionButton;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionComponentConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionTextDisplay;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionThumbnail;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelActionRowConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelContainerConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelFileConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelMediaGalleryConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelSectionConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelSeperatorConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelTextDisplay;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -41,6 +57,27 @@ public class CoreConfig {
|
||||
GsonBuilder builder = new GsonBuilder()
|
||||
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter())
|
||||
.registerTypeAdapter(Instant.class, new InstantAdapter())
|
||||
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
|
||||
.of(ComponentConfig.class, "type")
|
||||
.registerSubtype(TopLevelActionRowConfig.class, "actionRow")
|
||||
.registerSubtype(TopLevelSectionConfig.class, "section")
|
||||
.registerSubtype(TopLevelFileConfig.class, "fileDisplay")
|
||||
.registerSubtype(TopLevelMediaGalleryConfig.class, "mediaGallery")
|
||||
.registerSubtype(TopLevelSeperatorConfig.class, "separator")
|
||||
.registerSubtype(TopLevelContainerConfig.class, "container")
|
||||
.registerSubtype(TopLevelTextDisplay.class, "textDisplay"))
|
||||
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
|
||||
.of(ActionRowItemConfig.class, "type")
|
||||
.registerSubtype(ActionRowButtonConfig.class, "button"))
|
||||
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
|
||||
.of(SectionAccessoryConfig.class, "type")
|
||||
.registerSubtype(SectionButton.class, "button")
|
||||
.registerSubtype(SectionThumbnail.class, "thumbnail")
|
||||
)
|
||||
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
|
||||
.of(SectionComponentConfig.class, "type")
|
||||
.registerSubtype(SectionTextDisplay.class, "textDisplay")
|
||||
)
|
||||
.setPrettyPrinting();
|
||||
if(customJsonDeSerializers != null) {
|
||||
customJsonDeSerializers.forEach(customJsonSerializer ->
|
||||
|
||||
@@ -6,10 +6,10 @@ import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
|
||||
import net.dv8tion.jda.api.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.components.actionrow.ActionRow;
|
||||
import net.dv8tion.jda.api.components.buttons.Button;
|
||||
import net.dv8tion.jda.api.components.buttons.ButtonStyle;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -50,7 +50,7 @@ public class ComponentServiceBean implements ComponentService {
|
||||
} else {
|
||||
ActionRow lastRow = message.getActionRows().get(message.getActionRows().size() - 1);
|
||||
if(lastRow.getComponents().size() < MAX_BUTTONS_PER_ROW) {
|
||||
lastRow.getComponents().add(button);
|
||||
lastRow.getButtons().add(button);
|
||||
actionRows = message.getActionRows();
|
||||
} else {
|
||||
List<ActionRow> currentActionRows = new ArrayList<>(message.getActionRows());
|
||||
@@ -86,7 +86,7 @@ public class ComponentServiceBean implements ComponentService {
|
||||
public CompletableFuture<Void> removeComponentWithId(Message message, String componentId, Boolean rearrange) {
|
||||
List<ActionRow> actionRows = new ArrayList<>();
|
||||
if(Boolean.TRUE.equals(rearrange)) {
|
||||
List<net.dv8tion.jda.api.interactions.components.ActionComponent> components = new ArrayList<>();
|
||||
List<net.dv8tion.jda.api.components.ActionComponent> components = new ArrayList<>();
|
||||
message.getActionRows().forEach(row ->
|
||||
row
|
||||
.getComponents()
|
||||
@@ -112,8 +112,8 @@ public class ComponentServiceBean implements ComponentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActionRow> splitIntoActionRowsMax(List<net.dv8tion.jda.api.interactions.components.ActionComponent> allComponents) {
|
||||
List<List<net.dv8tion.jda.api.interactions.components.ActionComponent>> actionRows = ListUtils.partition(allComponents, MAX_BUTTONS_PER_ROW);
|
||||
public List<ActionRow> splitIntoActionRowsMax(List<net.dv8tion.jda.api.components.ActionComponent> allComponents) {
|
||||
List<List<net.dv8tion.jda.api.components.ActionComponent>> actionRows = ListUtils.partition(allComponents, MAX_BUTTONS_PER_ROW);
|
||||
return actionRows.stream().map(ActionRow::of).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.interactions.Interaction;
|
||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.components.actionrow.ActionRow;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
|
||||
@@ -260,56 +260,57 @@ public class InteractionServiceBean implements InteractionService {
|
||||
|
||||
public CompletableFuture<InteractionHook> replyMessageToSend(MessageToSend messageToSend, IReplyCallback callback) {
|
||||
ReplyCallbackAction action = null;
|
||||
if(messageToSend.getMessages() != null && !messageToSend.getMessages().isEmpty()) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
action = callback.reply(messageToSend.getMessages().get(0));
|
||||
}
|
||||
|
||||
if(messageToSend.getEmbeds() != null && !messageToSend.getEmbeds().isEmpty()) {
|
||||
if(action != null) {
|
||||
action = action.addEmbeds(messageToSend.getEmbeds().subList(0, Math.min(10, messageToSend.getEmbeds().size())));
|
||||
} else {
|
||||
action = callback.replyEmbeds(messageToSend.getEmbeds());
|
||||
if(messageToSend.getUseComponentsV2()) {
|
||||
action = callback.replyComponents(messageToSend.getComponents()).useComponentsV2();
|
||||
} else {
|
||||
if(messageToSend.getMessages() != null && !messageToSend.getMessages().isEmpty()) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
action = callback.reply(messageToSend.getMessages().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
if(messageToSend.getEmbeds() != null && !messageToSend.getEmbeds().isEmpty()) {
|
||||
if(action != null) {
|
||||
action = action.addEmbeds(messageToSend.getEmbeds().subList(0, Math.min(10, messageToSend.getEmbeds().size())));
|
||||
} else {
|
||||
action = callback.replyEmbeds(messageToSend.getEmbeds());
|
||||
}
|
||||
}
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
.getAttachedFiles()
|
||||
.stream()
|
||||
.map(AttachedFile::convertToFileUpload)
|
||||
.collect(Collectors.toList());
|
||||
if(action != null) {
|
||||
action.setFiles(attachedFiles);
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
action = callback.replyFiles(attachedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
// this should be last, because we are "faking" a message, by inserting a ., in case there has not been a reply yet
|
||||
// we could also throw an exception, but we are allowing this to go through
|
||||
List<ActionRow> actionRows = messageToSend.getActionRows();
|
||||
if(actionRows != null && !actionRows.isEmpty()) {
|
||||
if(action == null) {
|
||||
action = callback.reply(".");
|
||||
}
|
||||
action = action.setComponents(actionRows);
|
||||
AServer server;
|
||||
if(ContextUtils.isGuildKnown(callback)) {
|
||||
server = serverManagementService.loadServer(callback.getGuild().getIdLong());
|
||||
} else {
|
||||
server = null;
|
||||
}
|
||||
actionRows.forEach(components -> components.forEach(component -> {
|
||||
if(component instanceof ActionComponent) {
|
||||
String id = ((ActionComponent)component).getId();
|
||||
MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
|
||||
if(payload != null && payload.getPersistCallback()) {
|
||||
componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
|
||||
}
|
||||
if(action != null) {
|
||||
action.setFiles(attachedFiles);
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
action = callback.replyFiles(attachedFiles);
|
||||
}
|
||||
}));
|
||||
}
|
||||
// this should be last, because we are "faking" a message, by inserting a ., in case there has not been a reply yet
|
||||
// we could also throw an exception, but we are allowing this to go through
|
||||
List<ActionRow> actionRows = messageToSend.getActionRows();
|
||||
if(actionRows != null && !actionRows.isEmpty()) {
|
||||
if(action == null) {
|
||||
action = callback.reply(".");
|
||||
}
|
||||
action = action.setComponents(actionRows);
|
||||
AServer server;
|
||||
if(ContextUtils.isGuildKnown(callback)) {
|
||||
server = serverManagementService.loadServer(callback.getGuild().getIdLong());
|
||||
} else {
|
||||
server = null;
|
||||
}
|
||||
actionRows.forEach(components -> components.forEach(component -> {
|
||||
if(component instanceof ActionComponent) {
|
||||
String id = ((ActionComponent)component).getId();
|
||||
MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
|
||||
if(payload != null && payload.getPersistCallback()) {
|
||||
componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if(messageToSend.getEphemeral()) {
|
||||
@@ -328,7 +329,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
if(ContextUtils.isGuildKnown(callback)) {
|
||||
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(callback.getMessageChannel(), messageToSend);
|
||||
if (action != null) {
|
||||
action.setAllowedMentions(allowedMentions);
|
||||
action = action.setAllowedMentions(allowedMentions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import dev.sheldan.abstracto.core.interaction.modal.config.TextInputComponentSty
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.components.actionrow.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.ItemComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.text.TextInput;
|
||||
import net.dv8tion.jda.api.components.textinput.TextInput;
|
||||
import net.dv8tion.jda.api.interactions.modals.Modal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user