mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-16 10:56:08 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa22009007 | ||
|
|
7b7fdf781a |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
|||||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||||
VERSION=1.6.16
|
VERSION=1.6.8
|
||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class CreateAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT.intValue()));
|
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
||||||
Parameter rolePostName = Parameter
|
Parameter rolePostName = Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name(ASSIGNABLE_ROLE_PLACE_NAME_PARAMETER)
|
.name(ASSIGNABLE_ROLE_PLACE_NAME_PARAMETER)
|
||||||
@@ -95,7 +95,7 @@ public class CreateAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
.templated(true)
|
.templated(true)
|
||||||
.optional(true)
|
.optional(true)
|
||||||
.build();
|
.build();
|
||||||
List<ParameterValidator> rolePlaceDescriptionValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT.intValue()));
|
List<ParameterValidator> rolePlaceDescriptionValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
||||||
Parameter text = Parameter
|
Parameter text = Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name(ASSIGNABLE_ROLE_PLACE_TEXT_PARAMETER)
|
.name(ASSIGNABLE_ROLE_PLACE_TEXT_PARAMETER)
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>assignable-roles-int</artifactId>
|
<artifactId>assignable-roles-int</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
|
|||||||
} else {
|
} else {
|
||||||
leaderBoard = userExperienceService.findLeaderBoardData(server, page);
|
leaderBoard = userExperienceService.findLeaderBoardData(server, page);
|
||||||
}
|
}
|
||||||
List<CompletableFuture<?>> futures = new ArrayList<>();
|
List<CompletableFuture> futures = new ArrayList<>();
|
||||||
CompletableFuture<List<LeaderBoardEntryModel>> completableFutures = converter.fromLeaderBoard(leaderBoard, actorUser.getGuild().getIdLong());
|
CompletableFuture<List<LeaderBoardEntryModel>> completableFutures = converter.fromLeaderBoard(leaderBoard, actorUser.getGuild().getIdLong());
|
||||||
futures.add(completableFutures);
|
futures.add(completableFutures);
|
||||||
log.info("Rendering leaderboard for page {} in server {} for user {}.", page, actorUser.getId(), actorUser.getGuild().getId());
|
log.info("Rendering leaderboard for page {} in server {} for user {}.", page, actorUser.getId(), actorUser.getGuild().getId());
|
||||||
@@ -158,6 +158,7 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
|
|||||||
Parameter focusMe = Parameter
|
Parameter focusMe = Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name(FOCUS_PARAMETER)
|
.name(FOCUS_PARAMETER)
|
||||||
|
.validators(leaderBoardPageValidators)
|
||||||
.optional(true)
|
.optional(true)
|
||||||
.slashCommandOnly(true)
|
.slashCommandOnly(true)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-impl</artifactId>
|
<artifactId>giveaway-impl</artifactId>
|
||||||
|
|||||||
@@ -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.editMessageInAChannelFuture(messageToSend, messageChannel, giveaway.getMessageId())
|
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), messageChannel, giveaway.getMessageId())
|
||||||
.thenAccept(message -> {
|
.thenAccept(message -> {
|
||||||
self.persistAddedParticipant(member, giveawayId);
|
self.persistAddedParticipant(member, giveawayId);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-int</artifactId>
|
<artifactId>giveaway-int</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-impl</artifactId>
|
<artifactId>image-generation-impl</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-int</artifactId>
|
<artifactId>image-generation-int</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ 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.*;
|
||||||
@@ -19,6 +18,7 @@ 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,7 +28,6 @@ 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;
|
||||||
@@ -50,7 +49,6 @@ 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
|
||||||
@@ -80,6 +78,9 @@ 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;
|
||||||
|
|
||||||
@@ -159,21 +160,15 @@ 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<Pair<ServerChannelMessage, ServerChannelMessage>> embeddingMessages = embeddedMessages.stream()
|
List<ServerChannelMessage> reactionChannelMessages = embeddedMessages.stream()
|
||||||
.map(embeddedMessage -> Pair.of(ServerChannelMessage
|
.filter(embeddedMessage -> embeddedMessage.getDeletionComponentId() == null)
|
||||||
.builder()
|
.map(this::convertEmbedMessageToServerChannelMessage)
|
||||||
.serverId(embeddedMessage.getEmbeddingServer().getId())
|
.collect(Collectors.toList());
|
||||||
.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)
|
||||||
@@ -184,26 +179,67 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
|||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<CompletableFuture<Message>> editList = embeddingMessages.stream().map(messagePair -> {
|
List<CompletableFuture<Message>> reactionMessageFutures = messageService.retrieveMessages(reactionChannelMessages);
|
||||||
ServerChannelMessage embeddingMessage = messagePair.getLeft();
|
List<CompletableFuture<Message>> buttonMessageFutures = messageService.retrieveMessages(buttonChannelMessages);
|
||||||
ServerChannelMessage embeddedMessage = messagePair.getRight();
|
CompletableFutureList<Message> reactionFutureList = new CompletableFutureList<>(reactionMessageFutures);
|
||||||
MessageEmbedCleanupReplacementModel model = MessageEmbedCleanupReplacementModel
|
CompletableFutureList<Message> buttonFutureList = new CompletableFutureList<>(buttonMessageFutures);
|
||||||
.builder()
|
return reactionFutureList.getMainFuture()
|
||||||
.message(embeddedMessage)
|
.handle((unused, throwable) -> {
|
||||||
.build();
|
if(throwable != null) {
|
||||||
MessageToSend messageToSend =
|
log.warn("Embedded messages reaction message loading failed.", throwable);
|
||||||
templateService.renderEmbedTemplate(MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE, model, embeddingMessage.getServerId());
|
}
|
||||||
return channelService.editMessageInAChannelFuture(messageToSend, embeddingMessage.getServerId(), embeddingMessage.getChannelId(),
|
return self.removeReactions(reactionFutureList.getObjects());
|
||||||
embeddingMessage.getMessageId());
|
})
|
||||||
}).toList();
|
.thenCompose(Function.identity())
|
||||||
return FutureUtils.toSingleFutureGeneric(editList).whenComplete((unused, throwable) -> {
|
.thenCompose(unused -> buttonFutureList.getMainFuture())
|
||||||
if(throwable != null) {
|
.handle((unused, throwable) -> {
|
||||||
log.warn("Failed to cleanup embedded messages..", throwable);
|
if(throwable != null) {
|
||||||
}
|
log.warn("Embedded messages button message loading failed.", throwable);
|
||||||
self.deleteEmbeddedMessages(embeddedMessagesHandled, componentPayloadsToDelete);
|
}
|
||||||
});
|
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()
|
||||||
|
.serverId(embeddedMessage.getEmbeddingServer().getId())
|
||||||
|
.channelId(embeddedMessage.getEmbeddingChannel().getId())
|
||||||
|
.messageId(embeddedMessage.getEmbeddingMessageId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
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>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
|||||||
import dev.sheldan.abstracto.core.listener.async.jda.AsyncLeaveListener;
|
import dev.sheldan.abstracto.core.listener.async.jda.AsyncLeaveListener;
|
||||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||||
import dev.sheldan.abstracto.core.models.listener.MemberLeaveModel;
|
import dev.sheldan.abstracto.core.models.listener.MemberLeaveModel;
|
||||||
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
||||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
@@ -14,7 +13,6 @@ import dev.sheldan.abstracto.core.utils.FutureUtils;
|
|||||||
import dev.sheldan.abstracto.logging.config.LoggingFeatureDefinition;
|
import dev.sheldan.abstracto.logging.config.LoggingFeatureDefinition;
|
||||||
import dev.sheldan.abstracto.logging.config.LoggingPostTarget;
|
import dev.sheldan.abstracto.logging.config.LoggingPostTarget;
|
||||||
import dev.sheldan.abstracto.logging.model.template.MemberLeaveLogModel;
|
import dev.sheldan.abstracto.logging.model.template.MemberLeaveLogModel;
|
||||||
import java.util.List;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -43,17 +41,10 @@ public class LeaveLogger implements AsyncLeaveListener {
|
|||||||
.userId(listenerModel.getUser().getIdLong())
|
.userId(listenerModel.getUser().getIdLong())
|
||||||
.serverId(listenerModel.getServerId())
|
.serverId(listenerModel.getServerId())
|
||||||
.build();
|
.build();
|
||||||
List<RoleDisplay> roles = listenerModel
|
|
||||||
.getMember()
|
|
||||||
.getRoles()
|
|
||||||
.stream()
|
|
||||||
.map(RoleDisplay::fromRole)
|
|
||||||
.toList();
|
|
||||||
MemberLeaveLogModel model = MemberLeaveLogModel
|
MemberLeaveLogModel model = MemberLeaveLogModel
|
||||||
.builder()
|
.builder()
|
||||||
.leavingUser(leavingUser)
|
.leavingUser(leavingUser)
|
||||||
.user(UserDisplay.fromUser(listenerModel.getUser()))
|
.user(UserDisplay.fromUser(listenerModel.getUser()))
|
||||||
.roles(roles)
|
|
||||||
.build();
|
.build();
|
||||||
log.debug("Logging leave event for user {} in server {}.", listenerModel.getUser().getIdLong(), listenerModel.getServerId());
|
log.debug("Logging leave event for user {} in server {}.", listenerModel.getUser().getIdLong(), listenerModel.getServerId());
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(USER_LEAVE_TEMPLATE, model, listenerModel.getServerId());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(USER_LEAVE_TEMPLATE, model, listenerModel.getServerId());
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package dev.sheldan.abstracto.logging.model.template;
|
package dev.sheldan.abstracto.logging.model.template;
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||||
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
||||||
import java.util.List;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -14,5 +12,4 @@ import lombok.Setter;
|
|||||||
public class MemberLeaveLogModel {
|
public class MemberLeaveLogModel {
|
||||||
private ServerUser leavingUser;
|
private ServerUser leavingUser;
|
||||||
private UserDisplay user;
|
private UserDisplay user;
|
||||||
private List<RoleDisplay> roles;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ 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;
|
||||||
|
|
||||||
@@ -75,15 +76,16 @@ public class Ban extends AbstractConditionableCommand {
|
|||||||
duration = null;
|
duration = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class);
|
if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.USER)) {
|
||||||
if(member != null) {
|
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class);
|
||||||
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 {
|
||||||
User user = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, User.class);
|
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class);
|
||||||
|
Long userId = Long.parseLong(userIdStr);
|
||||||
return event.deferReply().submit()
|
return event.deferReply().submit()
|
||||||
.thenCompose((hook) -> self.banViaUserId(event, user.getIdLong(), reason, duration, hook))
|
.thenCompose((hook) -> self.banViaUserId(event, userId, reason, duration, hook))
|
||||||
.thenApply(commandResult -> CommandResult.fromSuccess());
|
.thenApply(commandResult -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ 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;
|
||||||
|
|
||||||
@@ -85,15 +86,16 @@ 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();
|
||||||
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.class);
|
if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.USER)) {
|
||||||
User user = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, User.class);
|
Member member = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, Member.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(user != null){
|
} else if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.STRING)){
|
||||||
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), user.getIdLong());
|
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class);
|
||||||
|
Long userId = Long.parseLong(userIdStr);
|
||||||
|
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(guild.getIdLong(), userId);
|
||||||
infractions = infractionManagementService.getInfractionsForUser(userInServer);
|
infractions = infractionManagementService.getInfractionsForUser(userInServer);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -223,9 +223,6 @@ 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();
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import dev.sheldan.abstracto.core.models.database.AChannel;
|
|||||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
||||||
import dev.sheldan.abstracto.core.models.property.SystemConfigProperty;
|
import dev.sheldan.abstracto.core.models.property.SystemConfigProperty;
|
||||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.service.*;
|
import dev.sheldan.abstracto.core.service.*;
|
||||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||||
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
||||||
@@ -150,43 +148,22 @@ public class StarboardServiceBean implements StarboardService {
|
|||||||
|
|
||||||
|
|
||||||
private CompletableFuture<StarboardPostModel> buildStarboardPostModel(CachedMessage message, Integer starCount) {
|
private CompletableFuture<StarboardPostModel> buildStarboardPostModel(CachedMessage message, Integer starCount) {
|
||||||
CompletableFuture<User> userFuture = userService.retrieveUserForId(message.getAuthor().getAuthorId());
|
return userService.retrieveUserForId(message.getAuthor().getAuthorId())
|
||||||
CompletableFuture<Member> memberFuture = memberService.retrieveMemberInServer(message.getAuthorAsServerUser());
|
.thenApply(user -> createStarboardModel(message, starCount, user))
|
||||||
CompletableFuture<StarboardPostModel> returnedFuture = new CompletableFuture<>();
|
|
||||||
FutureUtils.toSingleFuture(List.of(userFuture, memberFuture))
|
|
||||||
.whenComplete((any, error) -> {
|
|
||||||
User user = null;
|
|
||||||
if(!userFuture.isCompletedExceptionally()) {
|
|
||||||
user = userFuture.join();
|
|
||||||
} else {
|
|
||||||
log.warn("Failed to retrieve user for author {} of starboard post.", message.getAuthor().getAuthorId());
|
|
||||||
}
|
|
||||||
Member member = null;
|
|
||||||
if(!memberFuture.isCompletedExceptionally()) {
|
|
||||||
member = memberFuture.join();
|
|
||||||
} else {
|
|
||||||
log.warn("Failed to retrieve user for author {} of starboard post.", message.getAuthor().getAuthorId());
|
|
||||||
}
|
|
||||||
StarboardPostModel starboardModel = createStarboardModel(message, starCount, user, member);
|
|
||||||
returnedFuture.complete(starboardModel);
|
|
||||||
})
|
|
||||||
.exceptionally(throwable -> {
|
.exceptionally(throwable -> {
|
||||||
log.warn("Complete failure when handling creation starboard post of message {}.", message.getMessageId(), throwable);
|
log.warn("Failed to retrieve user for author {} of starboard post.", message.getAuthor().getAuthorId(), throwable);
|
||||||
returnedFuture.completeExceptionally(throwable);
|
return createStarboardModel(message, starCount, null);
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
return returnedFuture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private StarboardPostModel createStarboardModel(CachedMessage message, Integer starCount, net.dv8tion.jda.api.entities.User user, Member member) {
|
private StarboardPostModel createStarboardModel(CachedMessage message, Integer starCount, net.dv8tion.jda.api.entities.User user) {
|
||||||
Optional<GuildMessageChannel> channel = channelService.getMessageChannelFromServerOptional(message.getServerId(), message.getChannelId());
|
Optional<GuildMessageChannel> channel = channelService.getMessageChannelFromServerOptional(message.getServerId(), message.getChannelId());
|
||||||
Optional<Guild> guild = guildService.getGuildByIdOptional(message.getServerId());
|
Optional<Guild> guild = guildService.getGuildByIdOptional(message.getServerId());
|
||||||
String starLevelEmote = getAppropriateEmote(message.getServerId(), starCount);
|
String starLevelEmote = getAppropriateEmote(message.getServerId(), starCount);
|
||||||
return StarboardPostModel
|
return StarboardPostModel
|
||||||
.builder()
|
.builder()
|
||||||
.message(message)
|
.message(message)
|
||||||
.authorUser(user != null ? UserDisplay.fromUser(user) : null)
|
.author(user)
|
||||||
.authorMember(member != null ? MemberDisplay.fromMember(member) : null)
|
|
||||||
.sourceChannelId(message.getChannelId())
|
.sourceChannelId(message.getChannelId())
|
||||||
.channel(channel.orElse(null))
|
.channel(channel.orElse(null))
|
||||||
.starCount(starCount)
|
.starCount(starCount)
|
||||||
@@ -237,7 +214,7 @@ public class StarboardServiceBean implements StarboardService {
|
|||||||
int count = 3;
|
int count = 3;
|
||||||
List<CompletableFuture<StarStatsUser>> topStarGiverFutures = starboardPostReactorManagementService.retrieveTopStarGiver(serverId, count);
|
List<CompletableFuture<StarStatsUser>> topStarGiverFutures = starboardPostReactorManagementService.retrieveTopStarGiver(serverId, count);
|
||||||
List<CompletableFuture<StarStatsUser>> topStarReceiverFutures = starboardPostReactorManagementService.retrieveTopStarReceiver(serverId, count);
|
List<CompletableFuture<StarStatsUser>> topStarReceiverFutures = starboardPostReactorManagementService.retrieveTopStarReceiver(serverId, count);
|
||||||
List<CompletableFuture<?>> allFutures = new ArrayList<>();
|
List<CompletableFuture> allFutures = new ArrayList<>();
|
||||||
allFutures.addAll(topStarGiverFutures);
|
allFutures.addAll(topStarGiverFutures);
|
||||||
allFutures.addAll(topStarReceiverFutures);
|
allFutures.addAll(topStarReceiverFutures);
|
||||||
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,17 @@ package dev.sheldan.abstracto.starboard.model.template;
|
|||||||
|
|
||||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||||
import dev.sheldan.abstracto.core.models.context.ServerContext;
|
import dev.sheldan.abstracto.core.models.context.ServerContext;
|
||||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
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;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class StarboardPostModel extends ServerContext {
|
public class StarboardPostModel extends ServerContext {
|
||||||
private UserDisplay authorUser;
|
private User author;
|
||||||
private MemberDisplay authorMember;
|
|
||||||
private GuildMessageChannel channel;
|
private GuildMessageChannel channel;
|
||||||
private Long sourceChannelId;
|
private Long sourceChannelId;
|
||||||
private CachedMessage message;
|
private CachedMessage message;
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-impl</artifactId>
|
<artifactId>sticky-roles-impl</artifactId>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ 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;
|
||||||
@@ -18,8 +19,10 @@ 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;
|
||||||
@@ -44,18 +47,34 @@ 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);
|
||||||
Member targetMember = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, Member.class);
|
if(slashCommandParameterService.hasCommandOptionWithFullType(MEMBER_PARAMETER_NAME, event, OptionType.USER)) {
|
||||||
User targetUser = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, User.class);
|
Member targetMember = slashCommandParameterService.getCommandOption(MEMBER_PARAMETER_NAME, event, User.class, Member.class);
|
||||||
if(targetMember != null) {
|
|
||||||
stickyRoleService.setStickiness(targetMember, newState);
|
stickyRoleService.setStickiness(targetMember, newState);
|
||||||
|
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
} else {
|
} else {
|
||||||
stickyRoleService.setStickiness(targetUser, event.getGuild(), newState);
|
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());
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-int</artifactId>
|
<artifactId>sticky-roles-int</artifactId>
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class WikipediaServiceBean implements WikipediaService {
|
|||||||
Response response = okHttpClient.newCall(request).execute();
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
if(!response.isSuccessful()) {
|
if(!response.isSuccessful()) {
|
||||||
if(log.isDebugEnabled()) {
|
if(log.isDebugEnabled()) {
|
||||||
log.debug("Failed to retrieve wikipedia summary. Response had code {} with body {}.",
|
log.error("Failed to retrieve wikipedia summary. Response had code {} with body {}.",
|
||||||
response.code(), response.body());
|
response.code(), response.body());
|
||||||
}
|
}
|
||||||
throw new WikipediaRequestException(response.code());
|
throw new WikipediaRequestException(response.code());
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -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.17</version>
|
<version>1.6.9-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -182,8 +182,10 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UnParsedCommandResult getUnparsedCommandResult(Message message) {
|
public UnParsedCommandResult getUnparsedCommandResult(Message message) {
|
||||||
String commandName = getCommandName(message);
|
String contentStripped = message.getContentRaw();
|
||||||
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(message.getContentRaw(), message);
|
List<String> parameters = Arrays.asList(contentStripped.split(" "));
|
||||||
|
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(contentStripped, message);
|
||||||
|
String commandName = commandManager.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
||||||
Command foundCommand = commandManager.findCommandByParameters(commandName, unParsedParameter, message.getGuild().getIdLong()).orElse(null);
|
Command foundCommand = commandManager.findCommandByParameters(commandName, unParsedParameter, message.getGuild().getIdLong()).orElse(null);
|
||||||
return UnParsedCommandResult
|
return UnParsedCommandResult
|
||||||
.builder()
|
.builder()
|
||||||
@@ -192,9 +194,13 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommandName(Message message) {
|
public CompletableFuture<CommandParseResult> getParametersFromMessage(Message message) {
|
||||||
List<String> parameters = Arrays.asList( message.getContentRaw().split(" "));
|
UnParsedCommandResult result = getUnparsedCommandResult(message);
|
||||||
return commandManager.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
return getParsedParameters(result.getParameter(), result.getCommand(), message).thenApply(foundParameters -> CommandParseResult
|
||||||
|
.builder()
|
||||||
|
.command(result.getCommand())
|
||||||
|
.parameters(foundParameters)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<CommandParseResult> getParametersFromMessage(Message message, UnParsedCommandResult result) {
|
public CompletableFuture<CommandParseResult> getParametersFromMessage(Message message, UnParsedCommandResult result) {
|
||||||
@@ -426,7 +432,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
Parameter param = parameters.get(0);
|
Parameter param = parameters.get(0);
|
||||||
CommandParameterIterators iterators = new CommandParameterIterators(channelIterator, emoteIterator, memberIterator, roleIterator);
|
CommandParameterIterators iterators = new CommandParameterIterators(channelIterator, emoteIterator, memberIterator, roleIterator);
|
||||||
Set<CommandParameterHandler> usedParameterHandler = findNecessaryCommandParameterHandlers(parameters, unParsedCommandParameter);
|
Set<CommandParameterHandler> usedParameterHandler = findNecessaryCommandParameterHandlers(parameters, unParsedCommandParameter);
|
||||||
List<CompletableFuture<?>> futures = new ArrayList<>();
|
List<CompletableFuture> futures = new ArrayList<>();
|
||||||
// the actual parameters which were handled, might not coincide with the unparsed parameters
|
// the actual parameters which were handled, might not coincide with the unparsed parameters
|
||||||
// because we might ignore some parameters (for example referenced messages) in case the command does not use this as a parameter
|
// because we might ignore some parameters (for example referenced messages) in case the command does not use this as a parameter
|
||||||
int parsedParameter = 0;
|
int parsedParameter = 0;
|
||||||
@@ -443,7 +449,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
.getDependentFeatures()
|
.getDependentFeatures()
|
||||||
.stream()
|
.stream()
|
||||||
.map(s -> featureConfigService.getFeatureEnum(s))
|
.map(s -> featureConfigService.getFeatureEnum(s))
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
boolean parameterActiveForFeatures = false;
|
boolean parameterActiveForFeatures = false;
|
||||||
for (FeatureDefinition featureDefinition : featureDefinitions) {
|
for (FeatureDefinition featureDefinition : featureDefinitions) {
|
||||||
if(featureFlagService.getFeatureFlagValue(featureDefinition, message.getGuild().getIdLong())) {
|
if(featureFlagService.getFeatureFlagValue(featureDefinition, message.getGuild().getIdLong())) {
|
||||||
@@ -460,7 +466,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
try {
|
try {
|
||||||
if (handler.handles(param.getType(), value)) {
|
if (handler.handles(param.getType(), value)) {
|
||||||
if (handler.async()) {
|
if (handler.async()) {
|
||||||
CompletableFuture<?> future = handler.handleAsync(value, iterators, param, message, command);
|
CompletableFuture future = handler.handleAsync(value, iterators, param, message, command);
|
||||||
futures.add(future);
|
futures.add(future);
|
||||||
parsedParameters.add(ParseResult.builder().parameter(param).result(future).build());
|
parsedParameters.add(ParseResult.builder().parameter(param).result(future).build());
|
||||||
} else {
|
} else {
|
||||||
@@ -488,11 +494,11 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
|||||||
combinedFuture.thenAccept(aVoid -> {
|
combinedFuture.thenAccept(aVoid -> {
|
||||||
List<Object> allParamResults = parsedParameters.stream().map(o -> {
|
List<Object> allParamResults = parsedParameters.stream().map(o -> {
|
||||||
if (o.getResult() instanceof CompletableFuture) {
|
if (o.getResult() instanceof CompletableFuture) {
|
||||||
return ((CompletableFuture<?>) o.getResult()).join();
|
return ((CompletableFuture) o.getResult()).join();
|
||||||
} else {
|
} else {
|
||||||
return o.getResult();
|
return o.getResult();
|
||||||
}
|
}
|
||||||
}).toList();
|
}).collect(Collectors.toList());
|
||||||
List<ParseResult> parseResults = new ArrayList<>();
|
List<ParseResult> parseResults = new ArrayList<>();
|
||||||
for (int i = 0; i < allParamResults.size(); i++) {
|
for (int i = 0; i < allParamResults.size(); i++) {
|
||||||
if (allParamResults.get(i) != null) {
|
if (allParamResults.get(i) != null) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class SetPrefix extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<ParameterValidator> validators = Arrays.asList(MaxStringLengthValidator.max(10));
|
List<ParameterValidator> validators = Arrays.asList(MaxStringLengthValidator.max(10L));
|
||||||
Parameter newPrefixParameter = Parameter
|
Parameter newPrefixParameter = Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name("prefix")
|
.name("prefix")
|
||||||
|
|||||||
@@ -14,18 +14,14 @@ 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;
|
||||||
@@ -58,12 +54,6 @@ 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";
|
||||||
@@ -109,21 +99,6 @@ 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
|
||||||
@@ -131,7 +106,6 @@ 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);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -14,19 +13,11 @@ 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;
|
||||||
@@ -53,18 +44,6 @@ 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";
|
||||||
@@ -82,41 +61,12 @@ 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();
|
||||||
|
|
||||||
@@ -124,7 +74,6 @@ 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);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ 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;
|
||||||
@@ -25,7 +24,6 @@ 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;
|
||||||
@@ -58,9 +56,6 @@ 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";
|
||||||
@@ -119,26 +114,12 @@ 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);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -14,19 +13,11 @@ 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;
|
||||||
@@ -53,18 +44,6 @@ 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";
|
||||||
@@ -82,49 +61,16 @@ 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)
|
||||||
.supportsAutoComplete(true)
|
.templated(true).build();
|
||||||
.templated(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Parameter mode = Parameter
|
Parameter mode = Parameter
|
||||||
.builder()
|
.builder().name(MODE_PARAMETER)
|
||||||
.name(MODE_PARAMETER)
|
|
||||||
.type(String.class)
|
.type(String.class)
|
||||||
.supportsAutoComplete(true)
|
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,14 @@ 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;
|
||||||
@@ -58,12 +53,6 @@ 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;
|
||||||
@@ -84,28 +73,12 @@ 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();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class SetEmote extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<ParameterValidator> emoteKeyValidators = Arrays.asList(MaxStringLengthValidator.max(255));
|
List<ParameterValidator> emoteKeyValidators = Arrays.asList(MaxStringLengthValidator.max(255L));
|
||||||
Parameter emoteKey = Parameter
|
Parameter emoteKey = Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name(EMOTE_KEY_PARAMETER)
|
.name(EMOTE_KEY_PARAMETER)
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
package dev.sheldan.abstracto.core.commands.utility;
|
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.command.Command;
|
|
||||||
import dev.sheldan.abstracto.core.command.CommandAlternative;
|
|
||||||
import dev.sheldan.abstracto.core.command.CommandReceivedHandler;
|
|
||||||
import dev.sheldan.abstracto.core.command.config.features.CoreFeatureDefinition;
|
|
||||||
import dev.sheldan.abstracto.core.command.config.features.CoreFeatureMode;
|
|
||||||
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
|
|
||||||
import dev.sheldan.abstracto.core.command.service.CommandManager;
|
|
||||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
|
||||||
import dev.sheldan.abstracto.core.config.ListenerPriority;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.commands.SlashCommandSuggestionModel;
|
|
||||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
|
||||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
|
||||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
|
||||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
|
||||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
|
||||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
|
||||||
import java.util.Optional;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class SlashCommandSuggestor implements CommandAlternative {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FeatureModeService featureModeService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CommandManager commandManager;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CommandReceivedHandler commandReceivedHandler;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FeatureFlagService featureFlagService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TemplateService templateService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ChannelService channelService;
|
|
||||||
|
|
||||||
public static final String SUGGESTION_TEMPLATE_KEY = "slash_command_suggestion";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getPriority() {
|
|
||||||
return ListenerPriority.MEDIUM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message) {
|
|
||||||
boolean featureModeActive = featureModeService.featureModeActive(CoreFeatureDefinition.CORE_FEATURE, guild.getIdLong(), CoreFeatureMode.SUGGEST_SLASH_COMMANDS);
|
|
||||||
if(!featureModeActive) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String commandName = commandReceivedHandler.getCommandName(message);
|
|
||||||
Long guildId = message.getGuildIdLong();
|
|
||||||
Optional<Command> potentialCommand = commandManager.getCommandByNameOptional(commandName, true, guildId);
|
|
||||||
return potentialCommand.isPresent() && potentialCommand.get().getConfiguration().isSlashCommandOnly();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(UnParsedCommandParameter parameter, Message message) {
|
|
||||||
String commandName = commandReceivedHandler.getCommandName(message);
|
|
||||||
Long guildId = message.getGuildIdLong();
|
|
||||||
Optional<Command> potentialCommand = commandManager.getCommandByNameOptional(commandName, true, guildId);
|
|
||||||
// limitation to not check conditions if command is executable, I dont want to completely built the entire command context, as that would require
|
|
||||||
// to parse the parameters, therefore the major checks should suffice
|
|
||||||
if(potentialCommand.isPresent()) {
|
|
||||||
Command command = potentialCommand.get();
|
|
||||||
if(command.getConfiguration().isSlashCommandOnly()) {
|
|
||||||
boolean featureAvailable = featureFlagService.getFeatureFlagValue(command.getFeature(), guildId);
|
|
||||||
if(featureAvailable) {
|
|
||||||
boolean shouldNotifyUser = command.getFeatureModeLimitations().isEmpty();
|
|
||||||
for (FeatureMode featureModeLimitation : command.getFeatureModeLimitations()) {
|
|
||||||
if(featureModeService.featureModeActive(command.getFeature(), guildId, featureModeLimitation)) {
|
|
||||||
shouldNotifyUser = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(shouldNotifyUser) {
|
|
||||||
notifyUser(message, command, commandName, guildId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyUser(Message message, Command command, String commandName, Long guildId) {
|
|
||||||
String path = command.getConfiguration().getSlashCommandConfig().getSlashCommandPath();
|
|
||||||
SlashCommandSuggestionModel model = SlashCommandSuggestionModel
|
|
||||||
.builder()
|
|
||||||
.slashCommandPath(path)
|
|
||||||
.build();
|
|
||||||
Long userId = message.getAuthor().getIdLong();
|
|
||||||
log.info("Suggesting slash command for command {} to user {}.", commandName, userId);
|
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SUGGESTION_TEMPLATE_KEY, model, guildId);
|
|
||||||
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, message.getChannel()))
|
|
||||||
.thenAccept(unused -> {
|
|
||||||
log.debug("Successfully suggested command.");
|
|
||||||
}).exceptionally(throwable -> {
|
|
||||||
log.warn("Failed to suggest slash command for command {} to user {}", commandName, userId);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
|
import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
|
||||||
import dev.sheldan.abstracto.core.logging.OkHttpLogger;
|
import dev.sheldan.abstracto.core.logging.OkHttpLogger;
|
||||||
import dev.sheldan.abstracto.core.metric.OkHttpMetrics;
|
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.ActionRowButtonConfig;
|
||||||
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ActionRowItemConfig;
|
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.ComponentConfig;
|
||||||
@@ -36,15 +37,15 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class CoreConfig {
|
public class CoreConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BotService botService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OkHttpMetrics okHttpMetrics;
|
private OkHttpMetrics okHttpMetrics;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OkHttpLogger okHttpLogger;
|
private OkHttpLogger okHttpLogger;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OkHttpUserAgentSetter okHttpUserAgentSetter;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<CustomJsonSerializer> customJsonSerializers;
|
private List<CustomJsonSerializer> customJsonSerializers;
|
||||||
|
|
||||||
@@ -94,7 +95,6 @@ public class CoreConfig {
|
|||||||
return new OkHttpClient.Builder()
|
return new OkHttpClient.Builder()
|
||||||
.addInterceptor(okHttpMetrics)
|
.addInterceptor(okHttpMetrics)
|
||||||
.addInterceptor(okHttpLogger)
|
.addInterceptor(okHttpLogger)
|
||||||
.addInterceptor(okHttpUserAgentSetter)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user