mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-11 03:38:51 +00:00
Compare commits
16 Commits
abstracto-
...
abstracto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a72e48f690 | ||
|
|
a813af8b1f | ||
|
|
abee7b2732 | ||
|
|
4c71ffbb7e | ||
|
|
18050e2a8a | ||
|
|
a0d83763d4 | ||
|
|
0461c8e4ec | ||
|
|
072f32975a | ||
|
|
6810d28c50 | ||
|
|
650a9099c4 | ||
|
|
1217e03725 | ||
|
|
2e837d8738 | ||
|
|
9ddd386c6f | ||
|
|
4e1db26df7 | ||
|
|
de335a1e2a | ||
|
|
9ba0ed711e |
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@@ -19,11 +19,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'corretto'
|
||||
java-version: 8
|
||||
- name: Build with Maven
|
||||
run: mvn -B install --file abstracto-application/pom.xml
|
||||
- name: Setup sonarqube
|
||||
|
||||
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
@@ -6,13 +6,14 @@ jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Java for publishing to GitHub Packages
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'corretto'
|
||||
java-version: 8
|
||||
- name: Load current version
|
||||
id: version
|
||||
run: echo "version=$(mvn --file abstracto-application/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
|
||||
@@ -21,7 +22,7 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Deploy documentation to GitHub pages
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
repository-name: Sheldan/abstracto-docs
|
||||
target-folder: docs/${{ env.version }}
|
||||
@@ -29,7 +30,7 @@ jobs:
|
||||
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||
folder: abstracto-application/documentation/target/generated-docs
|
||||
- name: Deploy documentation to GitHub pages latest
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
repository-name: Sheldan/abstracto-docs
|
||||
target-folder: docs/current
|
||||
@@ -37,7 +38,7 @@ jobs:
|
||||
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||
folder: abstracto-application/documentation/target/generated-docs
|
||||
- name: Login to GitHub Packages Docker Registry
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: docker.pkg.github.com
|
||||
username: ${{ github.repository_owner }}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</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.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ public class Mines extends AbstractConditionableCommand {
|
||||
mines = slashCommandParameterService.getCommandOption(MINES_PARAMETER, event, Integer.class);
|
||||
}
|
||||
Integer credit = null;
|
||||
boolean economyEnabled = featureFlagService.getFeatureFlagValue(EntertainmentFeatureDefinition.ECONOMY, event.getGuild().getIdLong());
|
||||
long serverId = event.getGuild().getIdLong();
|
||||
boolean economyEnabled = featureFlagService.getFeatureFlagValue(EntertainmentFeatureDefinition.ECONOMY, serverId);
|
||||
if(economyEnabled){
|
||||
credit = 50;
|
||||
if(slashCommandParameterService.hasCommandOption(CREDITS_PARAMETER, event)) {
|
||||
@@ -97,10 +98,10 @@ public class Mines extends AbstractConditionableCommand {
|
||||
throw new NotEnoughCreditsException();
|
||||
}
|
||||
}
|
||||
MineBoard board = gameService.createBoard(width, height, mines);
|
||||
MineBoard board = gameService.createBoard(width, height, mines, serverId);
|
||||
board.setCreditsEnabled(economyEnabled);
|
||||
board.setUserId(event.getMember().getIdLong());
|
||||
board.setServerId(event.getGuild().getIdLong());
|
||||
board.setServerId(serverId);
|
||||
board.setCredits(credit);
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board);
|
||||
return interactionService.replyMessageToSend(messageToSend, event)
|
||||
@@ -128,7 +129,8 @@ public class Mines extends AbstractConditionableCommand {
|
||||
mines = (Integer) parameters.get(2);
|
||||
}
|
||||
Integer credit = null;
|
||||
boolean economyEnabled = featureFlagService.getFeatureFlagValue(EntertainmentFeatureDefinition.ECONOMY, commandContext.getGuild().getIdLong());
|
||||
long serverId = commandContext.getGuild().getIdLong();
|
||||
boolean economyEnabled = featureFlagService.getFeatureFlagValue(EntertainmentFeatureDefinition.ECONOMY, serverId);
|
||||
if(economyEnabled){
|
||||
credit = 50;
|
||||
if(parameters.size() == 4) {
|
||||
@@ -144,10 +146,10 @@ public class Mines extends AbstractConditionableCommand {
|
||||
throw new NotEnoughCreditsException();
|
||||
}
|
||||
}
|
||||
MineBoard board = gameService.createBoard(width, height, mines);
|
||||
MineBoard board = gameService.createBoard(width, height, mines, serverId);
|
||||
board.setCreditsEnabled(economyEnabled);
|
||||
board.setUserId(commandContext.getAuthor().getIdLong());
|
||||
board.setServerId(commandContext.getGuild().getIdLong());
|
||||
board.setServerId(serverId);
|
||||
board.setCredits(credit);
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board);
|
||||
List<CompletableFuture<Message>> futures = channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel());
|
||||
|
||||
@@ -39,6 +39,9 @@ public class MinesButtonClickedListener implements ButtonClickedListener {
|
||||
@Override
|
||||
public ButtonClickedListenerResult execute(ButtonClickedListenerModel model) {
|
||||
MineBoardPayload payload = (MineBoardPayload) model.getDeserializedPayload();
|
||||
if(model.getEvent().getUser().getIdLong() != payload.getMineBoard().getUserId()) {
|
||||
return ButtonClickedListenerResult.IGNORED;
|
||||
}
|
||||
MineBoard mineBoard = payload.getMineBoard();
|
||||
if(!mineBoard.getState().equals(GameService.MineResult.CONTINUE)) {
|
||||
return ButtonClickedListenerResult.IGNORED;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.sheldan.abstracto.entertainment.config.GamesFeatureConfig.MINES_CREDITS_FACTOR;
|
||||
import static dev.sheldan.abstracto.entertainment.config.GamesFeatureConfig.MINES_MINIMUM_MINES_RATIO;
|
||||
|
||||
@Component
|
||||
public class GameServiceBean implements GameService {
|
||||
@@ -51,9 +52,13 @@ public class GameServiceBean implements GameService {
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public MineBoard createBoard(Integer width, Integer height, Integer mines) {
|
||||
if(mines >= width * height || width > 5 || height > 5 || mines <= 0 || height == 0 || width == 0) {
|
||||
throw new InvalidGameBoardException();
|
||||
public MineBoard createBoard(Integer width, Integer height, Integer mines, Long serverId) {
|
||||
double minMinesRatio = configService.getDoubleValueOrConfigDefault(MINES_MINIMUM_MINES_RATIO, serverId);
|
||||
if(mines >= width * height || width > 5 || height > 5 || mines <= 1 || height <= 1 || width <= 1) {
|
||||
throw new InvalidGameBoardException(minMinesRatio);
|
||||
}
|
||||
if((double) mines / (width * height) < minMinesRatio) {
|
||||
throw new InvalidGameBoardException(minMinesRatio);
|
||||
}
|
||||
MineBoard mineBoard = generateEmptyBoard(width, height);
|
||||
mineBoard.setMineCount(mines);
|
||||
@@ -129,6 +134,7 @@ public class GameServiceBean implements GameService {
|
||||
.build();
|
||||
Optional<EconomyUser> economyUserOptional = economyUserManagementService.getUser(serverUser);
|
||||
if(economyUserOptional.isPresent()) {
|
||||
economyService.addCredits(economyUserOptional.get(), -credits);
|
||||
economyService.addCredits(economyUserOptional.get(), creditChange);
|
||||
}
|
||||
mineBoard.setCreditChange(creditChange);
|
||||
|
||||
@@ -26,6 +26,9 @@ abstracto.featureFlags.games.enabled=false
|
||||
abstracto.systemConfigs.minesCreditsFactor.name=minesCreditsFactor
|
||||
abstracto.systemConfigs.minesCreditsFactor.doubleValue=5
|
||||
|
||||
abstracto.systemConfigs.minesMinMineRatio.name=minesMinMineRatio
|
||||
abstracto.systemConfigs.minesMinMineRatio.doubleValue=0.2
|
||||
|
||||
# for now this is fine
|
||||
abstracto.systemConfigs.creditGambleJackpot.name=creditGambleJackpot
|
||||
abstracto.systemConfigs.creditGambleJackpot.longValue=1000
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
public class GamesFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String MINES_CREDITS_FACTOR = "minesCreditsFactor";
|
||||
public static final String MINES_MINIMUM_MINES_RATIO = "minesMinMineRatio";
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
@@ -19,7 +20,7 @@ public class GamesFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList(MINES_CREDITS_FACTOR);
|
||||
return Arrays.asList(MINES_CREDITS_FACTOR, MINES_MINIMUM_MINES_RATIO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
package dev.sheldan.abstracto.entertainment.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.abstracto.entertainment.model.exception.InvalidGameBoardExceptionModel;
|
||||
|
||||
public class InvalidGameBoardException extends AbstractoTemplatableException {
|
||||
|
||||
private final InvalidGameBoardExceptionModel model;
|
||||
|
||||
public InvalidGameBoardException(Double minRatio) {
|
||||
super();
|
||||
this.model = InvalidGameBoardExceptionModel
|
||||
.builder()
|
||||
.minMinesRatio(minRatio)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "invalid_mine_board_config_exception";
|
||||
@@ -10,6 +22,6 @@ public class InvalidGameBoardException extends AbstractoTemplatableException {
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.abstracto.entertainment.model.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class InvalidGameBoardExceptionModel {
|
||||
private Double minMinesRatio;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import dev.sheldan.abstracto.entertainment.model.command.games.MineBoard;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
public interface GameService {
|
||||
MineBoard createBoard(Integer width, Integer height, Integer mines);
|
||||
MineBoard createBoard(Integer width, Integer height, Integer mines, Long serverId);
|
||||
void persistMineBoardMessage(MineBoard mineBoard, Message message);
|
||||
void updateMineBoard(MineBoard mineBoard);
|
||||
void uncoverBoard(MineBoard mineBoard);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -104,7 +104,17 @@ public class Rank extends AbstractConditionableCommand {
|
||||
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(toRender);
|
||||
AUserExperience experienceObj = userExperienceManagementService.findUserInServer(aUserInAServer);
|
||||
log.info("Rendering rank for user {} in server {}.", toRender.getId(), toRender.getGuild().getId());
|
||||
rankModel.setExperienceToNextLevel(experienceLevelService.calculateExperienceToNextLevel(experienceObj.getCurrentLevel().getLevel(), experienceObj.getExperience()));
|
||||
Long currentExpNeeded = experienceObj.getCurrentLevel().getExperienceNeeded();
|
||||
Long experienceNeededToNextLevel = experienceLevelService.calculateExperienceToNextLevel(experienceObj.getCurrentLevel().getLevel(), experienceObj.getExperience());
|
||||
Long nextLevelExperience = experienceLevelService.calculateNextLevel(experienceObj.getCurrentLevel().getLevel()).getExperienceNeeded();
|
||||
Long levelExperience = nextLevelExperience - currentExpNeeded;
|
||||
Long inLevelExperience = experienceObj.getExperience() - currentExpNeeded;
|
||||
rankModel.setExperienceForCurrentLevel(currentExpNeeded);
|
||||
rankModel.setCurrentLevelPercentage(((float) inLevelExperience / levelExperience) * 100);
|
||||
rankModel.setLevelExperience(levelExperience);
|
||||
rankModel.setExperienceToNextLevel(experienceNeededToNextLevel);
|
||||
rankModel.setInLevelExperience(inLevelExperience);
|
||||
rankModel.setNextLevelExperience(nextLevelExperience);
|
||||
return templateService.renderEmbedTemplate(RANK_POST_EMBED_TEMPLATE, rankModel, toRender.getGuild().getIdLong());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@ public class JoiningUserRoleListener implements AsyncJoinListener {
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(MemberJoinModel model) {
|
||||
if(model.getMember().isPending()) {
|
||||
log.info("Joining member {} in guild {} is still pending - ignoring for experience role assignment.", model.getJoiningUser().getUserId(), model.getJoiningUser().getServerId());
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
Optional<AUserInAServer> userInAServerOptional = userInServerManagementService.loadUserOptional(model.getServerId(), model.getJoiningUser().getUserId());
|
||||
userInAServerOptional.ifPresent(aUserInAServer -> {
|
||||
Optional<AUserExperience> userExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(aUserInAServer.getUserInServerId());
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package dev.sheldan.abstracto.experience.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.listener.async.jda.AsyncUpdatePendingListener;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.models.listener.MemberUpdatePendingModel;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
import dev.sheldan.abstracto.experience.config.ExperienceFeatureDefinition;
|
||||
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
||||
import dev.sheldan.abstracto.experience.service.AUserExperienceService;
|
||||
import dev.sheldan.abstracto.experience.service.management.UserExperienceManagementService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* If a {@link Member member} updates the pending status, this {@link AsyncUpdatePendingListener listener} retrieves the previously stored {@link AUserExperience experience} and gives the
|
||||
* member the necessary {@link net.dv8tion.jda.api.entities.Role role} according to the current configuration, if any
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MemberPendingRoleListener implements AsyncUpdatePendingListener {
|
||||
|
||||
@Autowired
|
||||
private UserExperienceManagementService userExperienceManagementService;
|
||||
|
||||
@Autowired
|
||||
private AUserExperienceService userExperienceService;
|
||||
|
||||
@Autowired
|
||||
private UserInServerManagementService userInServerManagementService;
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(MemberUpdatePendingModel model) {
|
||||
Optional<AUserInAServer> userInAServerOptional = userInServerManagementService.loadUserOptional(model.getServerId(), model.getUser().getUserId());
|
||||
userInAServerOptional.ifPresent(aUserInAServer -> {
|
||||
Optional<AUserExperience> userExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(aUserInAServer.getUserInServerId());
|
||||
if(userExperienceOptional.isPresent()) {
|
||||
log.info("User {} updated pending status {} with previous experience. Setting up experience role again (if necessary).", model.getUser().getUserId(), model.getServerId());
|
||||
userExperienceService.syncForSingleUser(userExperienceOptional.get(), model.getMember()).thenAccept(result ->
|
||||
log.info("Finished re-assigning experience for update pending user {} in server {}.", model.getUser().getUserId(), model.getServerId())
|
||||
);
|
||||
} else {
|
||||
log.info("Member updating pending {} in server {} does not have any previous experience. Not setting up anything.", model.getUser().getUserId(), model.getServerId());
|
||||
}
|
||||
});
|
||||
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return ExperienceFeatureDefinition.EXPERIENCE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,9 +57,14 @@ public class ExperienceLevelServiceBean implements ExperienceLevelService {
|
||||
|
||||
@Override
|
||||
public Long calculateExperienceToNextLevel(Integer level, Long currentExperience) {
|
||||
AExperienceLevel nextLevel = experienceLevelManagementService.getLevelOptional(level + 1)
|
||||
.orElseThrow(() -> new AbstractoRunTimeException(String.format("Could not find level %s", level)));
|
||||
AExperienceLevel nextLevel = calculateNextLevel(level);
|
||||
return nextLevel.getExperienceNeeded() - currentExperience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AExperienceLevel calculateNextLevel(Integer level) {
|
||||
return experienceLevelManagementService.getLevelOptional(level + 1)
|
||||
.orElseThrow(() -> new AbstractoRunTimeException(String.format("Could not find level %s", level)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,9 +75,18 @@ public class JoiningUserRoleListenerTest {
|
||||
|
||||
@Test
|
||||
public void testUserWithOutExperienceRejoining() {
|
||||
when(model.getMember()).thenReturn(member);
|
||||
when(userExperienceManagementService.findByUserInServerIdOptional(USER_IN_SERVER_ID)).thenReturn(Optional.empty());
|
||||
testUnit.execute(model);
|
||||
verify(userExperienceService, times(0)).syncForSingleUser(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPendingUserJoining() {
|
||||
when(member.isPending()).thenReturn(true);
|
||||
when(model.getMember()).thenReturn(member);
|
||||
testUnit.execute(model);
|
||||
verify(userExperienceService, times(0)).syncForSingleUser(any(), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -23,6 +23,26 @@ public class RankModel {
|
||||
* The necessary experience to the next level up.
|
||||
*/
|
||||
private Long experienceToNextLevel;
|
||||
/**
|
||||
* Total experience needed for this level
|
||||
*/
|
||||
private Long experienceForCurrentLevel;
|
||||
/**
|
||||
* Percentage of progress within this level
|
||||
*/
|
||||
private Float currentLevelPercentage;
|
||||
/**
|
||||
* The total amount of experience needed for this level
|
||||
*/
|
||||
private Long levelExperience;
|
||||
/**
|
||||
* The experience which has been reached _within_ this level
|
||||
*/
|
||||
private Long inLevelExperience;
|
||||
/**
|
||||
* The experience needed to reach the next level
|
||||
*/
|
||||
private Long nextLevelExperience;
|
||||
/**
|
||||
* The member to show the rank for
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.sheldan.abstracto.experience.service;
|
||||
|
||||
import dev.sheldan.abstracto.experience.model.database.AExperienceLevel;
|
||||
|
||||
/**
|
||||
* Service responsible for operations on {@link dev.sheldan.abstracto.experience.model.database.AExperienceLevel experienceLevel}
|
||||
* This includes creating and calculations.
|
||||
@@ -20,6 +22,7 @@ public interface ExperienceLevelService {
|
||||
* @return The amount of experience required necessary to reach the next level
|
||||
*/
|
||||
Long calculateExperienceToNextLevel(Integer level, Long currentExperience);
|
||||
AExperienceLevel calculateNextLevel(Integer level);
|
||||
|
||||
/**
|
||||
* Calculates the required experience to reach this level. This calculated experience is relative, in the sense that
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -33,33 +33,32 @@ public class ReportContextCommandListener implements MessageContextCommandListen
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(MessageContextInteractionModel model) {
|
||||
Message targetMessage = model.getEvent().getTarget();
|
||||
if(targetMessage.getAuthor().getIdLong() == model.getEvent().getUser().getIdLong()) {
|
||||
interactionService.replyEmbed(ReactionReportServiceBean.REACTION_REPORT_OWN_MESSAGE_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(model.getEvent().getUser().getIdLong())
|
||||
.isBot(model.getEvent().getUser().isBot())
|
||||
.build();
|
||||
|
||||
if(!reactionReportService.allowedToReport(userReporting)) {
|
||||
log.info("User {} was reported on message {} in server {} within the cooldown. Ignoring.",
|
||||
targetMessage.getAuthor().getIdLong(), targetMessage.getIdLong(), targetMessage.getGuild().getIdLong());
|
||||
interactionService.replyEmbed(ReactionReportServiceBean.REACTION_REPORT_COOLDOWN_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
|
||||
reactionReportService.createReactionReport(targetMessage, userReporting, null).exceptionally(throwable -> {
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), targetMessage.getIdLong(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
model.getEvent().deferReply(true).queue(interactionHook -> {
|
||||
Message targetMessage = model.getEvent().getTarget();
|
||||
if(targetMessage.getAuthor().getIdLong() == model.getEvent().getUser().getIdLong()) {
|
||||
interactionService.sendMessageToInteraction(ReactionReportServiceBean.REACTION_REPORT_OWN_MESSAGE_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
return;
|
||||
}
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(model.getEvent().getUser().getIdLong())
|
||||
.isBot(model.getEvent().getUser().isBot())
|
||||
.build();
|
||||
if(!reactionReportService.allowedToReport(userReporting)) {
|
||||
log.info("User {} was reported on message {} in server {} within the cooldown. Ignoring.",
|
||||
targetMessage.getAuthor().getIdLong(), targetMessage.getIdLong(), targetMessage.getGuild().getIdLong());
|
||||
interactionService.sendMessageToInteraction(ReactionReportServiceBean.REACTION_REPORT_COOLDOWN_RESPONSE_TEMPLATE, new Object(),interactionHook);
|
||||
return;
|
||||
}
|
||||
reactionReportService.createReactionReport(targetMessage, userReporting, null).exceptionally(throwable -> {
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), targetMessage.getIdLong(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
interactionService.sendMessageToInteraction(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
});
|
||||
|
||||
interactionService.replyEmbed(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.dv8tion.jda.api.interactions.modals.ModalMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static dev.sheldan.abstracto.moderation.service.ReactionReportServiceBean.REACTION_REPORT_FAILURE_RESPONSE_TEMPLATE;
|
||||
import static dev.sheldan.abstracto.moderation.service.ReactionReportServiceBean.REACTION_REPORT_RESPONSE_TEMPLATE;
|
||||
|
||||
@Component
|
||||
@@ -46,27 +47,35 @@ public class ReportContextModalListener implements ModalInteractionListener {
|
||||
.map(ModalMapping::getAsString)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
messageCache.getMessageFromCache(payload.getServerId(), payload.getChannelId(), payload.getMessageId()).thenAccept(cachedMessage -> {
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(cachedMessage.getAuthor().getAuthorId())
|
||||
.isBot(cachedMessage.getAuthor().getIsBot())
|
||||
.build();
|
||||
reactionReportService.createReactionReport(cachedMessage, userReporting, context)
|
||||
.thenAccept(unused -> {
|
||||
interactionService.replyEmbed(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), model.getEvent());
|
||||
log.info("Handled modal for message report with id {} in guild {} in channel {} on message {}",
|
||||
model.getEvent().getModalId(), payload.getServerId(), payload.getChannelId(), payload.getMessageId());
|
||||
componentPayloadManagementService.deletePayload(payload.getModalId());
|
||||
}).exceptionally(throwable -> {
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), cachedMessage.getMessageId(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
model.getEvent().deferReply(true).queue(interactionHook -> {
|
||||
messageCache.getMessageFromCache(payload.getServerId(), payload.getChannelId(), payload.getMessageId()).thenAccept(cachedMessage -> {
|
||||
ServerUser userReporting = ServerUser
|
||||
.builder()
|
||||
.serverId(model.getServerId())
|
||||
.userId(cachedMessage.getAuthor().getAuthorId())
|
||||
.isBot(cachedMessage.getAuthor().getIsBot())
|
||||
.build();
|
||||
reactionReportService.createReactionReport(cachedMessage, userReporting, context)
|
||||
.thenAccept(unused -> {
|
||||
interactionService.sendMessageToInteraction(REACTION_REPORT_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
log.info("Handled modal for message report with id {} in guild {} in channel {} on message {}",
|
||||
model.getEvent().getModalId(), payload.getServerId(), payload.getChannelId(), payload.getMessageId());
|
||||
componentPayloadManagementService.deletePayload(payload.getModalId());
|
||||
}).exceptionally(throwable -> {
|
||||
interactionService.sendMessageToInteraction(REACTION_REPORT_FAILURE_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
log.error("Failed to create reaction report in server {} on message {} in channel {} with interaction.",
|
||||
model.getServerId(), cachedMessage.getMessageId(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}).exceptionally(throwable -> {
|
||||
interactionService.sendMessageToInteraction(REACTION_REPORT_FAILURE_RESPONSE_TEMPLATE, new Object(), interactionHook);
|
||||
log.error("Failed to load reported message for reporting message {} in channel {} with context.",
|
||||
model.getEvent().getMessage().getIdLong(), model.getEvent().getChannel().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}).exceptionally(throwable -> {
|
||||
log.error("Failed to load reported message.", throwable);
|
||||
return null;
|
||||
}, throwable -> {
|
||||
log.error("Failed to acknowledge modal interaction for report context modal listener in guild {} on message {}.", model.getServerId(),
|
||||
model.getEvent().getMessage() != null ? model.getEvent().getMessage().getIdLong() : 0, throwable);
|
||||
});
|
||||
|
||||
return ModalInteractionListenerResult.ACKNOWLEDGED;
|
||||
|
||||
@@ -71,6 +71,7 @@ public class ReactionReportServiceBean implements ReactionReportService {
|
||||
private static final String REACTION_REPORT_TEMPLATE_KEY = "reactionReport_notification";
|
||||
public static final String REACTION_REPORT_MODAL_ORIGIN = "reportMessageModal";
|
||||
public static final String REACTION_REPORT_RESPONSE_TEMPLATE = "reactionReport_response";
|
||||
public static final String REACTION_REPORT_FAILURE_RESPONSE_TEMPLATE = "reactionReport_failure_response";
|
||||
public static final String REACTION_REPORT_COOLDOWN_RESPONSE_TEMPLATE = "reactionReport_cooldown_response";
|
||||
public static final String REACTION_REPORT_OWN_MESSAGE_RESPONSE_TEMPLATE = "reactionReport_own_message_response";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</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.4.11</version>
|
||||
<version>1.4.15</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.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -22,6 +22,11 @@ public class ListenerExecutorConfig {
|
||||
return executorService.setupExecutorFor("joinListener");
|
||||
}
|
||||
|
||||
@Bean(name = "memberPendingUpdateExecutor")
|
||||
public TaskExecutor memberPendingUpdateExecutor() {
|
||||
return executorService.setupExecutorFor("memberPendingUpdateListener");
|
||||
}
|
||||
|
||||
@Bean(name = "leaveListenerExecutor")
|
||||
public TaskExecutor leaveListenerExecutor() {
|
||||
return executorService.setupExecutorFor("leaveListener");
|
||||
|
||||
@@ -106,6 +106,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
|
||||
if(messageToSend.getEphemeral()) {
|
||||
Interaction interaction = interactionHook.getInteraction();
|
||||
interactionHook.setEphemeral(messageToSend.getEphemeral());
|
||||
log.info("Sending ephemeral message to interaction in guild {} in channel {} for user {}.",
|
||||
interaction.getGuild().getIdLong(), interaction.getChannel().getId(),
|
||||
interaction.getMember().getIdLong());
|
||||
|
||||
@@ -62,8 +62,6 @@ public class ModalInteractionListenerBean extends ListenerAdapter {
|
||||
@Override
|
||||
public void onModalInteraction(@Nonnull ModalInteractionEvent event) {
|
||||
if(listenerList == null) return;
|
||||
// TODO remove this and make this configurable
|
||||
event.deferEdit().queue();
|
||||
CompletableFuture.runAsync(() -> self.executeListenerLogic(event), modalInteractionExecutor).exceptionally(throwable -> {
|
||||
log.error("Failed to execute listener logic in modal interaction event.", throwable);
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package dev.sheldan.abstracto.core.listener.async.jda;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
import dev.sheldan.abstracto.core.models.listener.MemberUpdatePendingModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdatePendingEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AsyncMemberPendingUpdateListenerBean extends ListenerAdapter {
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<AsyncUpdatePendingListener> listenerList;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("memberPendingUpdateExecutor")
|
||||
private TaskExecutor memberPendingUpdateListenerExecutor;
|
||||
|
||||
@Autowired
|
||||
private ListenerService listenerService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onGuildMemberUpdatePending(@Nonnull GuildMemberUpdatePendingEvent event) {
|
||||
if(listenerList == null) return;
|
||||
MemberUpdatePendingModel model = getModel(event);
|
||||
listenerList.forEach(joinListener -> listenerService.executeFeatureAwareListener(joinListener, model, memberPendingUpdateListenerExecutor));
|
||||
}
|
||||
|
||||
private MemberUpdatePendingModel getModel(GuildMemberUpdatePendingEvent event) {
|
||||
ServerUser serverUser = ServerUser
|
||||
.builder()
|
||||
.serverId(event.getGuild().getIdLong())
|
||||
.userId(event.getUser().getIdLong())
|
||||
.isBot(event.getUser().isBot())
|
||||
.build();
|
||||
return MemberUpdatePendingModel
|
||||
.builder()
|
||||
.user(serverUser)
|
||||
.member(event.getMember())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.listener.async.jda;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.listener.FeatureAwareListener;
|
||||
import dev.sheldan.abstracto.core.models.listener.MemberUpdatePendingModel;
|
||||
|
||||
public interface AsyncUpdatePendingListener extends FeatureAwareListener<MemberUpdatePendingModel, DefaultListenerResult> {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.abstracto.core.models.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.FeatureAwareListenerModel;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class MemberUpdatePendingModel implements FeatureAwareListenerModel {
|
||||
private ServerUser user;
|
||||
private Member member;
|
||||
|
||||
@Override
|
||||
public Long getServerId() {
|
||||
return user.getServerId();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>coverage</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -35,7 +35,7 @@
|
||||
<scm>
|
||||
<url>https://maven.pkg.github.com/Sheldan/abstracto</url>
|
||||
<developerConnection>scm:git:git@github.com:Sheldan/abstracto.git</developerConnection>
|
||||
<tag>abstracto-application-1.4.11</tag>
|
||||
<tag>abstracto-application-1.4.15</tag>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.4.11</version>
|
||||
<version>1.4.15</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
Reference in New Issue
Block a user