mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-07 01:38:32 +00:00
Compare commits
11 Commits
v1.6.14
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c791c063e3 | ||
|
|
d293d764db | ||
|
|
a7cd674cdd | ||
|
|
0abefe64e9 | ||
|
|
d1267605c1 | ||
|
|
b4ffea341c | ||
|
|
507c755809 | ||
|
|
9e0e92a530 | ||
|
|
d078b3fa87 | ||
|
|
71b7dd2383 | ||
|
|
ea0384490e |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||
VERSION=1.6.13
|
||||
VERSION=1.6.16
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>assignable-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
|
||||
} else {
|
||||
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());
|
||||
futures.add(completableFutures);
|
||||
log.info("Rendering leaderboard for page {} in server {} for user {}.", page, actorUser.getId(), actorUser.getGuild().getId());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>giveaway</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway-impl</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>giveaway</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway-int</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>image-generation</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation-impl</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>image-generation</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation-int</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>image-generation</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation-int</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.listener.async.jda.AsyncLeaveListener;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
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.service.PostTargetService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
@@ -13,6 +14,7 @@ import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.logging.config.LoggingFeatureDefinition;
|
||||
import dev.sheldan.abstracto.logging.config.LoggingPostTarget;
|
||||
import dev.sheldan.abstracto.logging.model.template.MemberLeaveLogModel;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -41,10 +43,17 @@ public class LeaveLogger implements AsyncLeaveListener {
|
||||
.userId(listenerModel.getUser().getIdLong())
|
||||
.serverId(listenerModel.getServerId())
|
||||
.build();
|
||||
List<RoleDisplay> roles = listenerModel
|
||||
.getMember()
|
||||
.getRoles()
|
||||
.stream()
|
||||
.map(RoleDisplay::fromRole)
|
||||
.toList();
|
||||
MemberLeaveLogModel model = MemberLeaveLogModel
|
||||
.builder()
|
||||
.leavingUser(leavingUser)
|
||||
.user(UserDisplay.fromUser(listenerModel.getUser()))
|
||||
.roles(roles)
|
||||
.build();
|
||||
log.debug("Logging leave event for user {} in server {}.", listenerModel.getUser().getIdLong(), listenerModel.getServerId());
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(USER_LEAVE_TEMPLATE, model, listenerModel.getServerId());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.sheldan.abstracto.logging.model.template;
|
||||
|
||||
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 java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -12,4 +14,5 @@ import lombok.Setter;
|
||||
public class MemberLeaveLogModel {
|
||||
private ServerUser leavingUser;
|
||||
private UserDisplay user;
|
||||
private List<RoleDisplay> roles;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
||||
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.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
||||
@@ -148,22 +150,43 @@ public class StarboardServiceBean implements StarboardService {
|
||||
|
||||
|
||||
private CompletableFuture<StarboardPostModel> buildStarboardPostModel(CachedMessage message, Integer starCount) {
|
||||
return userService.retrieveUserForId(message.getAuthor().getAuthorId())
|
||||
.thenApply(user -> createStarboardModel(message, starCount, user))
|
||||
CompletableFuture<User> userFuture = userService.retrieveUserForId(message.getAuthor().getAuthorId());
|
||||
CompletableFuture<Member> memberFuture = memberService.retrieveMemberInServer(message.getAuthorAsServerUser());
|
||||
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 -> {
|
||||
log.warn("Failed to retrieve user for author {} of starboard post.", message.getAuthor().getAuthorId(), throwable);
|
||||
return createStarboardModel(message, starCount, null);
|
||||
log.warn("Complete failure when handling creation starboard post of message {}.", message.getMessageId(), throwable);
|
||||
returnedFuture.completeExceptionally(throwable);
|
||||
return null;
|
||||
});
|
||||
return returnedFuture;
|
||||
}
|
||||
|
||||
private StarboardPostModel createStarboardModel(CachedMessage message, Integer starCount, net.dv8tion.jda.api.entities.User user) {
|
||||
private StarboardPostModel createStarboardModel(CachedMessage message, Integer starCount, net.dv8tion.jda.api.entities.User user, Member member) {
|
||||
Optional<GuildMessageChannel> channel = channelService.getMessageChannelFromServerOptional(message.getServerId(), message.getChannelId());
|
||||
Optional<Guild> guild = guildService.getGuildByIdOptional(message.getServerId());
|
||||
String starLevelEmote = getAppropriateEmote(message.getServerId(), starCount);
|
||||
return StarboardPostModel
|
||||
.builder()
|
||||
.message(message)
|
||||
.author(user)
|
||||
.authorUser(user != null ? UserDisplay.fromUser(user) : null)
|
||||
.authorMember(member != null ? MemberDisplay.fromMember(member) : null)
|
||||
.sourceChannelId(message.getChannelId())
|
||||
.channel(channel.orElse(null))
|
||||
.starCount(starCount)
|
||||
@@ -214,7 +237,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
int count = 3;
|
||||
List<CompletableFuture<StarStatsUser>> topStarGiverFutures = starboardPostReactorManagementService.retrieveTopStarGiver(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(topStarReceiverFutures);
|
||||
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -2,17 +2,19 @@ package dev.sheldan.abstracto.starboard.model.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
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.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
public class StarboardPostModel extends ServerContext {
|
||||
private User author;
|
||||
private UserDisplay authorUser;
|
||||
private MemberDisplay authorMember;
|
||||
private GuildMessageChannel channel;
|
||||
private Long sourceChannelId;
|
||||
private CachedMessage message;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>sticky-roles</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sticky-roles-impl</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>sticky-roles</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sticky-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>twitch</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>twitch</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -182,10 +182,8 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
}
|
||||
|
||||
public UnParsedCommandResult getUnparsedCommandResult(Message message) {
|
||||
String contentStripped = message.getContentRaw();
|
||||
List<String> parameters = Arrays.asList(contentStripped.split(" "));
|
||||
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(contentStripped, message);
|
||||
String commandName = commandManager.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
||||
String commandName = getCommandName(message);
|
||||
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(message.getContentRaw(), message);
|
||||
Command foundCommand = commandManager.findCommandByParameters(commandName, unParsedParameter, message.getGuild().getIdLong()).orElse(null);
|
||||
return UnParsedCommandResult
|
||||
.builder()
|
||||
@@ -194,13 +192,9 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
.build();
|
||||
}
|
||||
|
||||
public CompletableFuture<CommandParseResult> getParametersFromMessage(Message message) {
|
||||
UnParsedCommandResult result = getUnparsedCommandResult(message);
|
||||
return getParsedParameters(result.getParameter(), result.getCommand(), message).thenApply(foundParameters -> CommandParseResult
|
||||
.builder()
|
||||
.command(result.getCommand())
|
||||
.parameters(foundParameters)
|
||||
.build());
|
||||
public String getCommandName(Message message) {
|
||||
List<String> parameters = Arrays.asList( message.getContentRaw().split(" "));
|
||||
return commandManager.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
||||
}
|
||||
|
||||
public CompletableFuture<CommandParseResult> getParametersFromMessage(Message message, UnParsedCommandResult result) {
|
||||
@@ -432,7 +426,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
Parameter param = parameters.get(0);
|
||||
CommandParameterIterators iterators = new CommandParameterIterators(channelIterator, emoteIterator, memberIterator, roleIterator);
|
||||
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
|
||||
// because we might ignore some parameters (for example referenced messages) in case the command does not use this as a parameter
|
||||
int parsedParameter = 0;
|
||||
@@ -449,7 +443,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
.getDependentFeatures()
|
||||
.stream()
|
||||
.map(s -> featureConfigService.getFeatureEnum(s))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
boolean parameterActiveForFeatures = false;
|
||||
for (FeatureDefinition featureDefinition : featureDefinitions) {
|
||||
if(featureFlagService.getFeatureFlagValue(featureDefinition, message.getGuild().getIdLong())) {
|
||||
@@ -466,7 +460,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
try {
|
||||
if (handler.handles(param.getType(), value)) {
|
||||
if (handler.async()) {
|
||||
CompletableFuture future = handler.handleAsync(value, iterators, param, message, command);
|
||||
CompletableFuture<?> future = handler.handleAsync(value, iterators, param, message, command);
|
||||
futures.add(future);
|
||||
parsedParameters.add(ParseResult.builder().parameter(param).result(future).build());
|
||||
} else {
|
||||
@@ -494,11 +488,11 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
combinedFuture.thenAccept(aVoid -> {
|
||||
List<Object> allParamResults = parsedParameters.stream().map(o -> {
|
||||
if (o.getResult() instanceof CompletableFuture) {
|
||||
return ((CompletableFuture) o.getResult()).join();
|
||||
return ((CompletableFuture<?>) o.getResult()).join();
|
||||
} else {
|
||||
return o.getResult();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
List<ParseResult> parseResults = new ArrayList<>();
|
||||
for (int i = 0; i < allParamResults.size(); i++) {
|
||||
if (allParamResults.get(i) != null) {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
List<CompletableFuture<CachedReactions>> reactionFutures = new ArrayList<>();
|
||||
log.debug("Caching {} reactions.", message.getReactions().size());
|
||||
message.getReactions().forEach(messageReaction -> reactionFutures.add(getCachedReactionFromReaction(messageReaction)));
|
||||
List<CompletableFuture> allFutures = new ArrayList<>(reactionFutures);
|
||||
List<CompletableFuture<?>> allFutures = new ArrayList<>(reactionFutures);
|
||||
allFutures.add(referencedMessageFuture);
|
||||
FutureUtils.toSingleFuture(allFutures).thenAccept(aVoid ->
|
||||
{
|
||||
|
||||
@@ -21,6 +21,10 @@ abstracto.systemConfigs.confirmationTimeout.longValue=120
|
||||
abstracto.systemConfigs.maxMessages.name=maxMessages
|
||||
abstracto.systemConfigs.maxMessages.longValue=3
|
||||
|
||||
abstracto.featureModes.suggestSlashCommands.featureName=core
|
||||
abstracto.featureModes.suggestSlashCommands.mode=suggestSlashCommands
|
||||
abstracto.featureModes.suggestSlashCommands.enabled=true
|
||||
|
||||
abstracto.featureFlags.core.featureName=core
|
||||
abstracto.featureFlags.core.enabled=true
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package dev.sheldan.abstracto.core.commands.utility;
|
||||
|
||||
import static dev.sheldan.abstracto.core.commands.utility.SlashCommandSuggestor.SUGGESTION_TEMPLATE_KEY;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.CommandReceivedHandler;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.features.CoreFeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.command.config.features.CoreFeatureMode;
|
||||
import dev.sheldan.abstracto.core.command.service.CommandManager;
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
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.service.TemplateService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SlashCommandSuggestorTest {
|
||||
|
||||
@InjectMocks
|
||||
private SlashCommandSuggestor unitUnderTest;
|
||||
|
||||
@Mock
|
||||
private FeatureModeService featureModeService;
|
||||
|
||||
@Mock
|
||||
private CommandReceivedHandler commandReceivedHandler;
|
||||
|
||||
@Mock
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Mock
|
||||
private FeatureFlagService featureFlagService;
|
||||
|
||||
@Mock
|
||||
private TemplateService templateService;
|
||||
|
||||
@Mock
|
||||
private ChannelService channelService;
|
||||
|
||||
@Mock
|
||||
private Guild guild;
|
||||
|
||||
@Mock
|
||||
private Message message;
|
||||
|
||||
@Mock
|
||||
private Command command;
|
||||
|
||||
@Mock
|
||||
private FeatureMode featureMode;
|
||||
|
||||
private static final Long SERVER_ID = 1L;
|
||||
private static final String COMMAND_NAME = "commandName";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
when(guild.getIdLong()).thenReturn(SERVER_ID);
|
||||
when(message.getGuildIdLong()).thenReturn(SERVER_ID);
|
||||
when(message.getAuthor()).thenReturn(Mockito.mock(User.class));
|
||||
when(message.getChannel()).thenReturn(Mockito.mock(MessageChannelUnion.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotExecute_DueToFeatureMode() {
|
||||
when(featureModeService.featureModeActive(CoreFeatureDefinition.CORE_FEATURE, SERVER_ID, CoreFeatureMode.SUGGEST_SLASH_COMMANDS)).thenReturn(false);
|
||||
boolean shouldExecute = unitUnderTest.shouldExecute(null, guild, message);
|
||||
assertThat(shouldExecute).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotExecute_DueToNotFoundCommand() {
|
||||
when(featureModeService.featureModeActive(CoreFeatureDefinition.CORE_FEATURE, SERVER_ID, CoreFeatureMode.SUGGEST_SLASH_COMMANDS)).thenReturn(true);
|
||||
commandFound(null);
|
||||
boolean shouldExecute = unitUnderTest.shouldExecute(null, guild, message);
|
||||
assertThat(shouldExecute).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotExecute_DueToFoundCommandWhichIsNotSlashCommandOnly() {
|
||||
when(featureModeService.featureModeActive(CoreFeatureDefinition.CORE_FEATURE, SERVER_ID, CoreFeatureMode.SUGGEST_SLASH_COMMANDS)).thenReturn(true);
|
||||
commandSetup(false);
|
||||
boolean shouldExecute = unitUnderTest.shouldExecute(null, guild, message);
|
||||
assertThat(shouldExecute).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExecute_DueToFoundCommandWhichIsSlashCommandOnly() {
|
||||
when(featureModeService.featureModeActive(CoreFeatureDefinition.CORE_FEATURE, SERVER_ID, CoreFeatureMode.SUGGEST_SLASH_COMMANDS)).thenReturn(true);
|
||||
commandSetup(true);
|
||||
boolean shouldExecute = unitUnderTest.shouldExecute(null, guild, message);
|
||||
assertThat(shouldExecute).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotFindCommand() {
|
||||
commandFound(null);
|
||||
unitUnderTest.execute(null, message);
|
||||
verify(templateService, times(0)).renderEmbedTemplate(eq(SUGGESTION_TEMPLATE_KEY), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foundCommandIsNotSlashCommandOnly() {
|
||||
commandSetup(false);
|
||||
unitUnderTest.execute(null, message);
|
||||
verify(templateService, times(0)).renderEmbedTemplate(eq(SUGGESTION_TEMPLATE_KEY), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void featureNotEnabled() {
|
||||
commandSetup(true);
|
||||
when(featureFlagService.getFeatureFlagValue(any(), eq(SERVER_ID))).thenReturn(false);
|
||||
unitUnderTest.execute(null, message);
|
||||
verify(templateService, times(0)).renderEmbedTemplate(eq(SUGGESTION_TEMPLATE_KEY), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noFeatureModesAvailable() {
|
||||
commandSetup(true);
|
||||
when(command.getFeatureModeLimitations()).thenReturn(new ArrayList<>());
|
||||
when(featureFlagService.getFeatureFlagValue(any(), eq(SERVER_ID))).thenReturn(true);
|
||||
unitUnderTest.execute(null, message);
|
||||
verify(templateService).renderEmbedTemplate(eq(SUGGESTION_TEMPLATE_KEY), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void featureModesAvailable() {
|
||||
commandSetup(true);
|
||||
when(command.getFeatureModeLimitations()).thenReturn(Collections.singletonList(featureMode));
|
||||
when(featureFlagService.getFeatureFlagValue(any(), eq(SERVER_ID))).thenReturn(true);
|
||||
when(featureModeService.featureModeActive(any(), eq(SERVER_ID), any())).thenReturn(true);
|
||||
unitUnderTest.execute(null, message);
|
||||
verify(templateService).renderEmbedTemplate(eq(SUGGESTION_TEMPLATE_KEY), any(), any());
|
||||
}
|
||||
|
||||
private void commandSetup(boolean slashCommandOnly) {
|
||||
commandFound(command);
|
||||
CommandConfiguration commandConfiguration = CommandConfiguration
|
||||
.builder()
|
||||
.slashCommandOnly(slashCommandOnly)
|
||||
.build();
|
||||
when(command.getConfiguration()).thenReturn(commandConfiguration);
|
||||
}
|
||||
|
||||
private void commandFound(Command command) {
|
||||
when(commandReceivedHandler.getCommandName(message)).thenReturn(COMMAND_NAME);
|
||||
when(commandManager.getCommandByNameOptional(COMMAND_NAME, true, SERVER_ID)).thenReturn(Optional.ofNullable(command));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.command.config.features;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CoreFeatureMode implements FeatureMode {
|
||||
SUGGEST_SLASH_COMMANDS("suggestSlashCommands");
|
||||
|
||||
private final String key;
|
||||
|
||||
CoreFeatureMode(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -32,12 +32,12 @@ public class UnParsedCommandParameter {
|
||||
}
|
||||
if (m.group(1) != null) {
|
||||
String group = m.group(1);
|
||||
if(!group.equals("")) {
|
||||
if(!group.isEmpty()) {
|
||||
this.parameters.add(UnparsedCommandParameterPiece.builder().value(group).build());
|
||||
}
|
||||
} else {
|
||||
String group = m.group(2);
|
||||
if(!group.equals("")) {
|
||||
if(!group.isEmpty()) {
|
||||
this.parameters.add(UnparsedCommandParameterPiece.builder().value(group).build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package dev.sheldan.abstracto.core.interaction.slash;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.config.UserCommandConfig;
|
||||
import dev.sheldan.abstracto.core.utils.ContextUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
@@ -67,4 +71,13 @@ public class SlashCommandConfig {
|
||||
public String getUserSlashCompatibleCommandName() {
|
||||
return userCommandName != null ? userCommandName.toLowerCase(Locale.ROOT) : null;
|
||||
}
|
||||
|
||||
public String getSlashCommandPath() {
|
||||
String root = getSlashCompatibleRootName();
|
||||
String group = getSlashCompatibleGroupName();
|
||||
String command = getSlashCompatibleCommandName();
|
||||
return Stream.of(root, group, command)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.models.template.commands;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class SlashCommandSuggestionModel {
|
||||
private String slashCommandPath;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import net.dv8tion.jda.api.entities.Member;
|
||||
@Builder
|
||||
public class MemberDisplay {
|
||||
private String memberMention;
|
||||
private String avatarUrl;
|
||||
private String name;
|
||||
private Long userId;
|
||||
private String discriminator;
|
||||
@@ -25,6 +26,7 @@ public class MemberDisplay {
|
||||
.memberMention(member.getAsMention())
|
||||
.name(member.getEffectiveName())
|
||||
.discriminator(member.getUser().getDiscriminator())
|
||||
.avatarUrl(member.getEffectiveAvatarUrl())
|
||||
.serverId(member.getGuild().getIdLong())
|
||||
.userId(member.getIdLong())
|
||||
.build();
|
||||
|
||||
@@ -11,12 +11,14 @@ import net.dv8tion.jda.api.entities.Role;
|
||||
@Builder
|
||||
public class RoleDisplay {
|
||||
private String roleMention;
|
||||
private String roleName;
|
||||
private Long roleId;
|
||||
|
||||
public static RoleDisplay fromRole(Role role) {
|
||||
return RoleDisplay
|
||||
.builder()
|
||||
.roleId(role.getIdLong())
|
||||
.roleName(role.getName())
|
||||
.roleMention(role.getAsMention())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -15,13 +15,15 @@ public class UserDisplay {
|
||||
private String userMention;
|
||||
private String discriminator;
|
||||
private String name;
|
||||
private String globalName;
|
||||
private String avatarUrl;
|
||||
|
||||
public static UserDisplay fromUser(User user) {
|
||||
return UserDisplay
|
||||
.builder()
|
||||
.userMention(MemberUtils.getUserAsMention(user.getIdLong()))
|
||||
.userMention(user.getAsMention())
|
||||
.name(user.getEffectiveName())
|
||||
.globalName(user.getGlobalName())
|
||||
.discriminator(user.getDiscriminator())
|
||||
.id(user.getIdLong())
|
||||
.avatarUrl(user.getEffectiveAvatarUrl())
|
||||
|
||||
@@ -12,7 +12,7 @@ public class FutureUtils {
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
}
|
||||
|
||||
public static CompletableFuture<Void> toSingleFuture(List<CompletableFuture> futures) {
|
||||
public static CompletableFuture<Void> toSingleFuture(List<CompletableFuture<?>> futures) {
|
||||
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.14</version>
|
||||
<version>1.6.17-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -33,7 +33,7 @@
|
||||
<connection>scm:git:${project.scm.url}</connection>
|
||||
<developerConnection>scm:git:${project.scm.url}</developerConnection>
|
||||
<url>https://github.com/Sheldan/abstracto.git</url>
|
||||
<tag>v1.6.14</tag>
|
||||
<tag>v1.6.0</tag>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user