mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-25 14:53:26 +00:00
Compare commits
11 Commits
release-20
...
81b1688d97
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81b1688d97 | ||
|
|
3500ec4123 | ||
|
|
4495b12e84 | ||
|
|
1f1cb0ed34 | ||
|
|
a778518475 | ||
|
|
fa62353aee | ||
|
|
2f125d0101 | ||
|
|
4dc92fe49b | ||
|
|
5e908f6837 | ||
|
|
95a2813c34 | ||
|
|
d844e09f4d |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||
VERSION=1.6.18
|
||||
VERSION=1.6.20
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -313,107 +313,107 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
||||
Long userInServerId = userInAServer.getUserInServerId();
|
||||
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
||||
AUserExperience aUserExperience = aUserExperienceOptional.orElseGet(() -> userExperienceManagementService.createUserInServer(userInAServer));
|
||||
if(Boolean.FALSE.equals(aUserExperience.getExperienceGainDisabled())) {
|
||||
List<AExperienceLevel> levels = experienceLevelManagementService.getLevelConfig();
|
||||
levels.sort(Comparator.comparing(AExperienceLevel::getExperienceNeeded));
|
||||
|
||||
Long minExp = configService.getLongValueOrConfigDefault(ExperienceFeatureConfig.MIN_EXP_KEY, serverId);
|
||||
Long maxExp = configService.getLongValueOrConfigDefault(ExperienceFeatureConfig.MAX_EXP_KEY, serverId);
|
||||
Double multiplier = configService.getDoubleValueOrConfigDefault(ExperienceFeatureConfig.EXP_MULTIPLIER_KEY, serverId);
|
||||
Long experienceRange = maxExp - minExp + 1;
|
||||
Long gainedExperience = (secureRandom.nextInt(experienceRange.intValue()) + minExp);
|
||||
gainedExperience = (long) Math.floor(gainedExperience * multiplier);
|
||||
|
||||
List<AExperienceRole> roles = experienceRoleManagementService.getExperienceRolesForServer(server);
|
||||
roles.sort(Comparator.comparing(role -> role.getLevel().getLevel()));
|
||||
|
||||
log.debug("Handling {}. The user gains {}.", userInServerId, gainedExperience);
|
||||
|
||||
Long oldExperience = aUserExperience.getExperience();
|
||||
Long newExperienceCount = oldExperience + gainedExperience;
|
||||
aUserExperience.setExperience(newExperienceCount);
|
||||
AExperienceLevel newLevel = calculateLevel(levels, newExperienceCount);
|
||||
RoleCalculationResult result = RoleCalculationResult
|
||||
.builder()
|
||||
.build();
|
||||
boolean userChangesLevel = !Objects.equals(newLevel.getLevel(), aUserExperience.getCurrentLevel().getLevel());
|
||||
Integer oldLevel = aUserExperience.getCurrentLevel() != null ? aUserExperience.getCurrentLevel().getLevel() : 0;
|
||||
if(userChangesLevel) {
|
||||
log.info("User {} in server {} changed level. New {}, Old {}.", member.getIdLong(),
|
||||
member.getGuild().getIdLong(), newLevel.getLevel(),
|
||||
oldLevel);
|
||||
aUserExperience.setCurrentLevel(newLevel);
|
||||
AExperienceRole calculatedNewRole = experienceRoleService.calculateRole(roles, newLevel.getLevel());
|
||||
Long oldRoleId = aUserExperience.getCurrentExperienceRole() != null && aUserExperience.getCurrentExperienceRole().getRole() != null ? aUserExperience.getCurrentExperienceRole().getRole().getId() : null;
|
||||
Long newRoleId = calculatedNewRole != null && calculatedNewRole.getRole() != null ? calculatedNewRole.getRole().getId() : null;
|
||||
result.setOldRoleId(oldRoleId);
|
||||
result.setNewRoleId(newRoleId);
|
||||
if(message != null
|
||||
&& aUserExperience.getLevelUpNotification()
|
||||
&& featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, serverId, ExperienceFeatureMode.LEVEL_UP_NOTIFICATION)) {
|
||||
LevelUpNotificationModel model = LevelUpNotificationModel
|
||||
.builder()
|
||||
.memberDisplay(MemberDisplay.fromMember(member))
|
||||
.oldExperience(oldExperience)
|
||||
.newExperience(newExperienceCount)
|
||||
.newLevel(newLevel.getLevel())
|
||||
.oldLevel(oldLevel)
|
||||
.newRole(oldRoleId != null ? RoleDisplay.fromRole(oldRoleId) : null)
|
||||
.newRole(newRoleId != null ? RoleDisplay.fromRole(newRoleId) : null)
|
||||
.build();
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate("experience_level_up_notification", model, serverId);
|
||||
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, message.getChannel())).thenAccept(unused -> {
|
||||
log.info("Sent level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to send level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
aUserExperience.setCurrentExperienceRole(calculatedNewRole);
|
||||
}
|
||||
aUserExperience.setMessageCount(aUserExperience.getMessageCount() + 1L);
|
||||
if(userChangesLevel && featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, server, ExperienceFeatureMode.LEVEL_ACTION)) {
|
||||
levelActionService.applyLevelActionsToUser(aUserExperience, oldLevel)
|
||||
.thenAccept(unused -> {
|
||||
log.info("Executed level actions for user {}.", userInServerId);
|
||||
})
|
||||
.exceptionally(throwable -> {
|
||||
log.warn("Failed to execute level actions for user {}.", userInServerId, throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if(aUserExperienceOptional.isEmpty()) {
|
||||
userExperienceManagementService.saveUser(aUserExperience);
|
||||
}
|
||||
if(!Objects.equals(result.getOldRoleId(), result.getNewRoleId())) {
|
||||
if(result.getOldRoleId() != null && result.getNewRoleId() != null) {
|
||||
roleService.updateRolesIds(member, Arrays.asList(result.getOldRoleId()), Arrays.asList(result.getNewRoleId())).thenAccept(unused -> {
|
||||
log.debug("Removed role {} from and added role {} to member {} in server {}.", result.getOldRoleId(), result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to remove role {} from and add role {} to member {} in server {}.", result.getOldRoleId(), result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
if(result.getOldRoleId() != null) {
|
||||
roleService.removeRoleFromMemberAsync(member, result.getOldRoleId()).thenAccept(unused -> {
|
||||
log.debug("Removed role {} from member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to remove role {} from member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if(result.getNewRoleId() != null) {
|
||||
roleService.addRoleToMemberAsync(member, result.getNewRoleId()).thenAccept(unused -> {
|
||||
log.debug("Added role {} to member {} in server {}.", result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to add role {} to member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (aUserExperience.getExperienceGainDisabled().equals(Boolean.TRUE)) {
|
||||
log.debug("Experience gain was disabled. User did not gain any experience.");
|
||||
return;
|
||||
}
|
||||
List<AExperienceLevel> levels = experienceLevelManagementService.getLevelConfig();
|
||||
levels.sort(Comparator.comparing(AExperienceLevel::getExperienceNeeded));
|
||||
|
||||
Long minExp = configService.getLongValueOrConfigDefault(ExperienceFeatureConfig.MIN_EXP_KEY, serverId);
|
||||
Long maxExp = configService.getLongValueOrConfigDefault(ExperienceFeatureConfig.MAX_EXP_KEY, serverId);
|
||||
Double multiplier = configService.getDoubleValueOrConfigDefault(ExperienceFeatureConfig.EXP_MULTIPLIER_KEY, serverId);
|
||||
Long experienceRange = maxExp - minExp + 1;
|
||||
Long gainedExperience = (secureRandom.nextInt(experienceRange.intValue()) + minExp);
|
||||
gainedExperience = (long) Math.floor(gainedExperience * multiplier);
|
||||
|
||||
List<AExperienceRole> roles = experienceRoleManagementService.getExperienceRolesForServer(server);
|
||||
roles.sort(Comparator.comparing(role -> role.getLevel().getLevel()));
|
||||
|
||||
log.debug("Handling {}. The user gains {}.", userInServerId, gainedExperience);
|
||||
|
||||
Long oldExperience = aUserExperience.getExperience();
|
||||
Long newExperienceCount = oldExperience + gainedExperience;
|
||||
aUserExperience.setExperience(newExperienceCount);
|
||||
AExperienceLevel newLevel = calculateLevel(levels, newExperienceCount);
|
||||
RoleCalculationResult result = RoleCalculationResult
|
||||
.builder()
|
||||
.build();
|
||||
boolean userChangesLevel = !Objects.equals(newLevel.getLevel(), aUserExperience.getCurrentLevel().getLevel());
|
||||
Integer oldLevel = aUserExperience.getCurrentLevel() != null ? aUserExperience.getCurrentLevel().getLevel() : 0;
|
||||
if(userChangesLevel) {
|
||||
log.info("User {} in server {} changed level. New {}, Old {}.", member.getIdLong(),
|
||||
member.getGuild().getIdLong(), newLevel.getLevel(),
|
||||
oldLevel);
|
||||
aUserExperience.setCurrentLevel(newLevel);
|
||||
AExperienceRole calculatedNewRole = experienceRoleService.calculateRole(roles, newLevel.getLevel());
|
||||
Long oldRoleId = aUserExperience.getCurrentExperienceRole() != null && aUserExperience.getCurrentExperienceRole().getRole() != null ? aUserExperience.getCurrentExperienceRole().getRole().getId() : null;
|
||||
Long newRoleId = calculatedNewRole != null && calculatedNewRole.getRole() != null ? calculatedNewRole.getRole().getId() : null;
|
||||
result.setOldRoleId(oldRoleId);
|
||||
result.setNewRoleId(newRoleId);
|
||||
if(message != null
|
||||
&& aUserExperience.getLevelUpNotification()
|
||||
&& featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, serverId, ExperienceFeatureMode.LEVEL_UP_NOTIFICATION)) {
|
||||
LevelUpNotificationModel model = LevelUpNotificationModel
|
||||
.builder()
|
||||
.memberDisplay(MemberDisplay.fromMember(member))
|
||||
.oldExperience(oldExperience)
|
||||
.newExperience(newExperienceCount)
|
||||
.newLevel(newLevel.getLevel())
|
||||
.oldLevel(oldLevel)
|
||||
.newRole(oldRoleId != null ? RoleDisplay.fromRole(oldRoleId) : null)
|
||||
.newRole(newRoleId != null ? RoleDisplay.fromRole(newRoleId) : null)
|
||||
.build();
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate("experience_level_up_notification", model, serverId);
|
||||
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, message.getChannel())).thenAccept(unused -> {
|
||||
log.info("Sent level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to send level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
aUserExperience.setCurrentExperienceRole(calculatedNewRole);
|
||||
}
|
||||
aUserExperience.setMessageCount(aUserExperience.getMessageCount() + 1L);
|
||||
if(userChangesLevel && featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, server, ExperienceFeatureMode.LEVEL_ACTION)) {
|
||||
levelActionService.applyLevelActionsToUser(aUserExperience, oldLevel)
|
||||
.thenAccept(unused -> {
|
||||
log.info("Executed level actions for user {}.", userInServerId);
|
||||
})
|
||||
.exceptionally(throwable -> {
|
||||
log.warn("Failed to execute level actions for user {}.", userInServerId, throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if(aUserExperienceOptional.isEmpty()) {
|
||||
userExperienceManagementService.saveUser(aUserExperience);
|
||||
}
|
||||
if(!Objects.equals(result.getOldRoleId(), result.getNewRoleId())) {
|
||||
if(result.getOldRoleId() != null && result.getNewRoleId() != null) {
|
||||
roleService.updateRolesIds(member, List.of(result.getOldRoleId()), List.of(result.getNewRoleId())).thenAccept(unused -> {
|
||||
log.debug("Removed role {} from and added role {} to member {} in server {}.", result.getOldRoleId(), result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to remove role {} from and add role {} to member {} in server {}.", result.getOldRoleId(), result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
if(result.getOldRoleId() != null) {
|
||||
roleService.removeRoleFromMemberAsync(member, result.getOldRoleId()).thenAccept(unused -> {
|
||||
log.debug("Removed role {} from member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to remove role {} from member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
if(result.getNewRoleId() != null) {
|
||||
roleService.addRoleToMemberAsync(member, result.getNewRoleId()).thenAccept(unused -> {
|
||||
log.debug("Added role {} to member {} in server {}.", result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||
}).exceptionally(throwable -> {
|
||||
log.warn("Failed to add role {} to member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
||||
public LeaderBoardEntry getRankOfUserInServer(AUserInAServer userInAServer) {
|
||||
log.debug("Retrieving rank for {}", userInAServer.getUserReference().getId());
|
||||
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
||||
if(!aUserExperienceOptional.isPresent()) {
|
||||
if(aUserExperienceOptional.isEmpty()) {
|
||||
throw new NoExperienceTrackedException();
|
||||
}
|
||||
Integer rank = 0;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ExperienceLevelServiceBean implements ExperienceLevelService {
|
||||
if(level < 0) {
|
||||
throw new IllegalArgumentException("Level should not be less to 0.");
|
||||
}
|
||||
return 5L * (level * level) + 50 * level + 100;
|
||||
return 5L * ((long) level * level) + 50L * level + 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ExperienceRoleServiceBean implements ExperienceRoleService {
|
||||
@Override
|
||||
public CompletableFuture<Void> unsetRoles(List<ARole> rolesToUnset, GuildMessageChannel messageChannel) {
|
||||
List<AExperienceRole> rolesInServer = experienceRoleManagementService.getRolesInServer(rolesToUnset);
|
||||
Integer totalCount = 0;
|
||||
int totalCount = 0;
|
||||
for (AExperienceRole aExperienceRole : rolesInServer) {
|
||||
totalCount += aExperienceRole.getUsers().size();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package dev.sheldan.abstracto.experience.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
@@ -17,11 +20,9 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
@Component
|
||||
public class RunTimeExperienceService {
|
||||
|
||||
private Map<Long,Map<Long, Instant>> runtimeExperience = new HashMap<>();
|
||||
@Getter
|
||||
private final Map<Long,Map<Long, Instant>> runtimeExperience = new HashMap<>();
|
||||
private static final Lock lock = new ReentrantLock();
|
||||
public Map<Long, Map<Long, Instant>> getRuntimeExperience() {
|
||||
return runtimeExperience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquires the lock of the runtime experience data structure. Operations on it should only be done, while holding the lock
|
||||
@@ -39,6 +40,7 @@ public class RunTimeExperienceService {
|
||||
|
||||
public void cleanupRunTimeStorage() {
|
||||
Instant now = Instant.now();
|
||||
Set<Long> serverIdsToRemove = new HashSet<>();
|
||||
runtimeExperience.forEach((serverId, userInstantMap) -> {
|
||||
List<Long> userIdsToRemove = new ArrayList<>();
|
||||
userInstantMap.forEach((userId, instant) -> {
|
||||
@@ -47,6 +49,10 @@ public class RunTimeExperienceService {
|
||||
}
|
||||
});
|
||||
userIdsToRemove.forEach(userInstantMap::remove);
|
||||
if(userInstantMap.isEmpty()) {
|
||||
serverIdsToRemove.add(serverId);
|
||||
}
|
||||
});
|
||||
serverIdsToRemove.forEach(runtimeExperience::remove);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.sheldan.abstracto.experience.service;
|
||||
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RuntimeExperienceServiceTest {
|
||||
|
||||
@Test
|
||||
public void shouldCleanExpiredExperience() {
|
||||
RunTimeExperienceService experienceService = new RunTimeExperienceService();
|
||||
Map<Long, Instant> mapValue = new HashMap<>(Map.of(2L, Instant.now().minusSeconds(5)));
|
||||
experienceService.getRuntimeExperience().put(1L, mapValue);
|
||||
experienceService.cleanupRunTimeStorage();
|
||||
assertThat(experienceService.getRuntimeExperience()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldLeaveExperienceIfNotYetExpired() {
|
||||
RunTimeExperienceService experienceService = new RunTimeExperienceService();
|
||||
Map<Long, Instant> mapValue2 = new HashMap<>(Map.of(3L, Instant.now().plusSeconds(5)));
|
||||
experienceService.getRuntimeExperience().put(2L, mapValue2);
|
||||
experienceService.cleanupRunTimeStorage();
|
||||
assertThat(experienceService.getRuntimeExperience().get(2L)).containsKey(3L);
|
||||
assertThat(experienceService.getRuntimeExperience()).hasSize(1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway-impl</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>giveaway</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>giveaway</artifactId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>image-generation</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -13,9 +13,13 @@ import dev.sheldan.abstracto.core.models.listener.MessageReceivedModel;
|
||||
import dev.sheldan.abstracto.core.service.MessageCache;
|
||||
import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||
import dev.sheldan.abstracto.linkembed.config.LinkEmbedFeatureDefinition;
|
||||
import dev.sheldan.abstracto.linkembed.model.MessageEmbedLink;
|
||||
import dev.sheldan.abstracto.linkembed.service.MessageEmbedService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.Event;
|
||||
@@ -27,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -67,37 +70,51 @@ public class MessageEmbedListener implements MessageReceivedListener {
|
||||
}
|
||||
String messageRaw = message.getContentRaw();
|
||||
List<MessageEmbedLink> links = messageEmbedService.getLinksInMessage(messageRaw);
|
||||
for (MessageEmbedLink messageEmbedLink : links) {
|
||||
messageRaw = messageRaw.replace(messageEmbedLink.getWholeUrl(), "");
|
||||
}
|
||||
boolean deleteMessage = StringUtils.isBlank(messageRaw) && !links.isEmpty() && message.getAttachments().isEmpty();
|
||||
if(!links.isEmpty()) {
|
||||
Long messageId = message.getIdLong();
|
||||
Long channelId = message.getChannelIdLong();
|
||||
Long serverId = message.getGuildIdLong();
|
||||
log.debug("We found {} links to embed in message {} in channel {} in guild {}.", links.size(), message.getId(), message.getChannel().getId(), message.getGuild().getId());
|
||||
Long userEmbeddingUserInServerId = userInServerManagementService.loadOrCreateUser(message.getMember()).getUserInServerId();
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (MessageEmbedLink messageEmbedLink : links) {
|
||||
// potentially support foreign linked servers
|
||||
// potentially support foreign linked servers?
|
||||
if(!messageEmbedLink.getServerId().equals(message.getGuild().getIdLong())) {
|
||||
log.info("Link for message {} was from a foreign server {}. Do not embed.", messageEmbedLink.getMessageId(), messageEmbedLink.getServerId());
|
||||
continue;
|
||||
}
|
||||
messageRaw = messageRaw.replace(messageEmbedLink.getWholeUrl(), "");
|
||||
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> self.embedSingleLink(message, userEmbeddingUserInServerId, cachedMessage);
|
||||
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
||||
.thenAccept(cachedMessageConsumer)
|
||||
.exceptionally(throwable -> {
|
||||
log.error("Error when embedding link for message {}", message.getId(), throwable);
|
||||
return null;
|
||||
});
|
||||
Function<CachedMessage, CompletableFuture<Void>> cachedMessageConsumer = cachedMessage -> self.embedSingleLink(message, userEmbeddingUserInServerId, cachedMessage);
|
||||
futures.add(messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
||||
.thenCompose(cachedMessageConsumer));
|
||||
}
|
||||
if(!futures.isEmpty()) {
|
||||
// only delete the message if all futures go through
|
||||
new CompletableFutureList<>(futures).getMainFuture().thenAccept(unused -> {
|
||||
if(deleteMessage) {
|
||||
messageService.deleteMessageInChannelInServer(serverId, channelId, messageId);
|
||||
}
|
||||
}).thenAccept(unused -> {
|
||||
log.info("Deleted embedding message server {} channel {} message {}.", serverId, channelId, messageId);
|
||||
}).exceptionally(throwable -> {
|
||||
log.info("Failed to delete embedding message or to embed message server {} channel {} message {}.", serverId, channelId, messageId, throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
if(StringUtils.isBlank(messageRaw) && !links.isEmpty() && message.getAttachments().isEmpty()) {
|
||||
messageService.deleteMessage(message);
|
||||
if(deleteMessage) {
|
||||
return ConsumableListenerResult.DELETED;
|
||||
}
|
||||
if(!links.isEmpty()) {
|
||||
} else if(!links.isEmpty()) {
|
||||
return ConsumableListenerResult.PROCESSED;
|
||||
}
|
||||
return ConsumableListenerResult.IGNORED;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void embedSingleLink(Message message, Long cause, CachedMessage cachedMessage) {
|
||||
public CompletableFuture<Void> embedSingleLink(Message message, Long cause, CachedMessage cachedMessage) {
|
||||
GuildMemberMessageChannel context = GuildMemberMessageChannel
|
||||
.builder()
|
||||
.guildChannel(message.getGuildChannel())
|
||||
@@ -107,7 +124,7 @@ public class MessageEmbedListener implements MessageReceivedListener {
|
||||
.build();
|
||||
log.info("Embedding link to message {} in channel {} in server {} to channel {} and server {}.",
|
||||
cachedMessage.getMessageId(), cachedMessage.getChannelId(), cachedMessage.getServerId(), message.getChannel().getId(), message.getGuild().getId());
|
||||
messageEmbedService.embedLink(cachedMessage, message.getGuildChannel(), cause , context).thenAccept(unused ->
|
||||
return messageEmbedService.embedLink(cachedMessage, message.getGuildChannel(), cause , context).thenAccept(unused ->
|
||||
metricService.incrementCounter(MESSAGE_EMBED_CREATED)
|
||||
).exceptionally(throwable -> {
|
||||
log.error("Failed to embed link towards message {} in channel {} in sever {} linked from message {} in channel {} in server {}.", cachedMessage.getMessageId(), cachedMessage.getChannelId(), cachedMessage.getServerId(),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -130,13 +130,14 @@ public class RemindServiceBean implements ReminderService {
|
||||
if(remindIn.getSeconds() < 60) {
|
||||
reminder.setJobTriggerKey(null);
|
||||
log.info("Directly scheduling unremind for reminder {}, because it was below the threshold.", reminder.getId());
|
||||
long nanos = Math.max(remindIn.toNanos(), Duration.ofSeconds(5).toNanos()); // should be good enough, if its too small, it doesnt find the reminder
|
||||
instantReminderScheduler.schedule(() -> {
|
||||
try {
|
||||
self.executeReminder(reminder.getId());
|
||||
} catch (Exception exception) {
|
||||
log.error("Failed to remind immediately.", exception);
|
||||
}
|
||||
}, remindIn.toNanos(), TimeUnit.NANOSECONDS);
|
||||
}, nanos, TimeUnit.NANOSECONDS);
|
||||
} else {
|
||||
HashMap<Object, Object> parameters = new HashMap<>();
|
||||
parameters.put("reminderId", reminder.getId().toString());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -15,7 +15,7 @@ public class InstantSlashCommandParameterProvider implements SlashCommandParamet
|
||||
return SlashCommandOptionTypeMapping
|
||||
.builder()
|
||||
.type(Instant.class)
|
||||
.optionTypes(Arrays.asList(OptionType.INTEGER))
|
||||
.optionTypes(Arrays.asList(OptionType.STRING))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import dev.sheldan.abstracto.core.metric.service.MetricService;
|
||||
import dev.sheldan.abstracto.core.metric.service.MetricTag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.GenericEvent;
|
||||
import net.dv8tion.jda.api.events.http.HttpRequestEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.requests.Route;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -19,8 +21,13 @@ public class JDAMetrics extends ListenerAdapter {
|
||||
private MetricService metricService;
|
||||
|
||||
public static final String JDA_EVENT_METRIC = "jda.event";
|
||||
public static final String JDA_REQUEST_METRIC = "jda.request";
|
||||
public static final String EVENT_CLASS = "event.class";
|
||||
private final HashMap<Class, CounterMetric> coveredEvents = new HashMap<>();
|
||||
public static final String HTTP_METHOD = "http.method";
|
||||
public static final String HTTP_URL = "http.url";
|
||||
public static final String HTTP_KEY = "http.key";
|
||||
private final HashMap<Class<?>, CounterMetric> coveredEvents = new HashMap<>();
|
||||
private final HashMap<String, CounterMetric> coveredRoutes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onGenericEvent(GenericEvent event) {
|
||||
@@ -39,4 +46,25 @@ public class JDAMetrics extends ListenerAdapter {
|
||||
metricService.incrementCounter(coveredEvents.get(event.getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHttpRequest(HttpRequestEvent event) {
|
||||
Route baseRoute = event.getRequest().getRoute().getBaseRoute();
|
||||
String urlKey = baseRoute.toString();
|
||||
if(!coveredRoutes.containsKey(urlKey)) {
|
||||
CounterMetric metric =
|
||||
CounterMetric
|
||||
.builder()
|
||||
.tagList(Arrays.asList(
|
||||
MetricTag.getTag(HTTP_METHOD, baseRoute.getMethod().name()),
|
||||
MetricTag.getTag(HTTP_URL, baseRoute.getRoute()),
|
||||
MetricTag.getTag(HTTP_KEY, baseRoute.toString())))
|
||||
.name(JDA_REQUEST_METRIC)
|
||||
.build();
|
||||
metricService.registerCounter(metric, "Requests towards URL " + urlKey);
|
||||
coveredRoutes.put(urlKey, metric);
|
||||
log.info("Registering new metric for URL {}. There are now {} metrics.", urlKey, coveredRoutes.size());
|
||||
}
|
||||
metricService.incrementCounter(coveredRoutes.get(urlKey));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ import lombok.experimental.SuperBuilder;
|
||||
public class TopLevelContainerConfig extends ContainerConfig implements ComponentConfig {
|
||||
@Override
|
||||
public ComponentTypeConfig getType() {
|
||||
return ComponentTypeConfig.SECTION;
|
||||
return ComponentTypeConfig.CONTAINER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -10,11 +10,11 @@ public class DurationFormatException extends AbstractoRunTimeException implement
|
||||
private final DurationFormatExceptionModel model;
|
||||
|
||||
|
||||
public DurationFormatException(String wrongFormat, List<String> validFormats) {
|
||||
public DurationFormatException(String invalidFormat, List<String> validFormats) {
|
||||
super("Duration format exception ");
|
||||
this.model = DurationFormatExceptionModel
|
||||
.builder()
|
||||
.invalidFormat(wrongFormat)
|
||||
.invalidFormat(invalidFormat)
|
||||
.validFormats(validFormats)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.InstantFormatExceptionModel;
|
||||
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
|
||||
public class InstantFormatException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final InstantFormatExceptionModel model;
|
||||
|
||||
|
||||
public InstantFormatException(String invalidFormat) {
|
||||
super("Instant format exception ");
|
||||
this.model = InstantFormatExceptionModel
|
||||
.builder()
|
||||
.invalidFormat(invalidFormat)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "instant_invalid_time_format_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
public class InstantFormatExceptionModel implements Serializable {
|
||||
private final String invalidFormat;
|
||||
}
|
||||
@@ -3,12 +3,18 @@ package dev.sheldan.abstracto.core.utils;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.exception.AbstractoTemplatedException;
|
||||
import dev.sheldan.abstracto.core.exception.DurationFormatException;
|
||||
import dev.sheldan.abstracto.core.exception.InstantFormatException;
|
||||
import java.time.Instant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.ISnowflake;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.utils.TimeFormat;
|
||||
import net.dv8tion.jda.api.utils.Timestamp;
|
||||
import net.dv8tion.jda.api.utils.cache.SnowflakeCacheView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -18,40 +24,65 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
public class ParseUtils {
|
||||
|
||||
private ParseUtils() {
|
||||
|
||||
}
|
||||
|
||||
private static Pattern messageRegex = Pattern.compile("(?<number>\\d+)(?<unit>[ywdhms]+)");
|
||||
private static List<String> validDuration = Arrays.asList("w", "d", "h", "m", "s");
|
||||
private static final Pattern MESSAGE_REGEX = Pattern.compile("(?<number>\\d+)(?<unit>[ywdhms]+)");
|
||||
private static final List<String> VALID_DURATION = Arrays.asList("w", "d", "h", "m", "s");
|
||||
|
||||
public static Duration parseDuration(String textToParseFrom) {
|
||||
if(textToParseFrom == null || textToParseFrom.isEmpty()) {
|
||||
throw new DurationFormatException("", validDuration);
|
||||
throw new DurationFormatException("", VALID_DURATION);
|
||||
}
|
||||
Matcher matcher = ParseUtils.messageRegex.matcher(textToParseFrom);
|
||||
Duration start = Duration.ZERO;
|
||||
Duration targetDuration;
|
||||
try {
|
||||
Timestamp discordTimeStamp = TimeFormat.parse(textToParseFrom);
|
||||
targetDuration = Duration.between(Instant.now(), discordTimeStamp.toInstant());
|
||||
return targetDuration;
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// ignore
|
||||
}
|
||||
Matcher matcher = ParseUtils.MESSAGE_REGEX.matcher(textToParseFrom);
|
||||
targetDuration = Duration.ZERO;
|
||||
String rest = textToParseFrom;
|
||||
while(matcher.find()) {
|
||||
String unit = matcher.group("unit");
|
||||
String number = matcher.group("number");
|
||||
rest = rest.replace(matcher.group(0), "");
|
||||
long parsed = Long.parseLong(number);
|
||||
switch (unit) {
|
||||
case "w": start = start.plus(Duration.ofDays(parsed * 7)); break;
|
||||
case "d": start = start.plus(Duration.ofDays(parsed)); break;
|
||||
case "h": start = start.plus(Duration.ofHours(parsed)); break;
|
||||
case "m": start = start.plus(Duration.ofMinutes(parsed)); break;
|
||||
case "s": start = start.plus(Duration.ofSeconds(parsed)); break;
|
||||
default: throw new DurationFormatException(unit, validDuration);
|
||||
}
|
||||
targetDuration = switch (unit) {
|
||||
case "w" -> targetDuration.plus(Duration.ofDays(parsed * 7));
|
||||
case "d" -> targetDuration.plus(Duration.ofDays(parsed));
|
||||
case "h" -> targetDuration.plus(Duration.ofHours(parsed));
|
||||
case "m" -> targetDuration.plus(Duration.ofMinutes(parsed));
|
||||
case "s" -> targetDuration.plus(Duration.ofSeconds(parsed));
|
||||
default -> throw new DurationFormatException(unit, VALID_DURATION);
|
||||
};
|
||||
}
|
||||
if(!rest.equals("")) {
|
||||
throw new DurationFormatException(rest, validDuration);
|
||||
throw new DurationFormatException(rest, VALID_DURATION);
|
||||
}
|
||||
return start;
|
||||
return targetDuration;
|
||||
}
|
||||
|
||||
public static Instant parseInstant(String textToParseFrom) {
|
||||
if(textToParseFrom == null || textToParseFrom.isEmpty()) {
|
||||
throw new DurationFormatException("", VALID_DURATION);
|
||||
}
|
||||
try {
|
||||
Timestamp discordTimeStamp = TimeFormat.parse(textToParseFrom);
|
||||
return discordTimeStamp.toInstant();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// ignore
|
||||
}
|
||||
if(StringUtils.isNumeric(textToParseFrom)) {
|
||||
return Instant.ofEpochSecond(Integer.parseInt(textToParseFrom));
|
||||
}
|
||||
throw new InstantFormatException(textToParseFrom);
|
||||
}
|
||||
|
||||
public static Role parseRoleFromText(String text, Guild guild) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-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.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<properties>
|
||||
<maven.build.timestamp.format>yyyy/MM/dd HH:mm</maven.build.timestamp.format>
|
||||
<jda.version>6.2.0</jda.version>
|
||||
<jda.version>6.3.1</jda.version>
|
||||
<asciidoctor.maven.plugin.version>2.2.6</asciidoctor.maven.plugin.version>
|
||||
<asciidoctorj.pdf.version>1.5.3</asciidoctorj.pdf.version>
|
||||
<asciidoctorj.version>2.3.0</asciidoctorj.version>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</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.6.19-SNAPSHOT</version>
|
||||
<version>1.6.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
Reference in New Issue
Block a user