mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-12 03:07:59 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
194930f9db | ||
|
|
7f12ac7107 | ||
|
|
81b1688d97 | ||
|
|
3500ec4123 | ||
|
|
4495b12e84 | ||
|
|
1f1cb0ed34 | ||
|
|
a778518475 | ||
|
|
fa62353aee | ||
|
|
2f125d0101 | ||
|
|
4dc92fe49b | ||
|
|
5e908f6837 | ||
|
|
95a2813c34 | ||
|
|
d844e09f4d | ||
|
|
8251074aab | ||
|
|
4180a07243 | ||
|
|
cf9e5f67f6 | ||
|
|
ae53784da2 |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
|||||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||||
VERSION=1.6.17
|
VERSION=1.6.20
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
|||||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.components.buttons.ButtonStyle;
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -60,9 +59,6 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ChannelService channelService;
|
private ChannelService channelService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GuildService guildService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmoteService emoteService;
|
private EmoteService emoteService;
|
||||||
|
|
||||||
@@ -131,9 +127,18 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
String buttonId = componentService.generateComponentId();
|
String buttonId = componentService.generateComponentId();
|
||||||
String emoteMarkdown = emoji != null ? emoji.getFormatted() : null;
|
String emoteMarkdown = emoji != null ? emoji.getFormatted() : null;
|
||||||
if (assignableRolePlace.getMessageId() != null) {
|
if (assignableRolePlace.getMessageId() != null) {
|
||||||
|
AssignablePostMessage model = prepareAssignablePostMessageModel(assignableRolePlace);
|
||||||
|
model.getRoles().add(AssignablePostRole
|
||||||
|
.builder()
|
||||||
|
.componentId(buttonId)
|
||||||
|
.emoteMarkDown(emoteMarkdown)
|
||||||
|
.description(description)
|
||||||
|
.build());
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(ASSIGNABLE_ROLES_POST_TEMPLATE_KEY, model, assignableRolePlace.getServer().getId());
|
||||||
log.debug("Assignable role place {} has already message post with ID {} - updating.", assignableRolePlace.getId(), assignableRolePlace.getMessageId());
|
log.debug("Assignable role place {} has already message post with ID {} - updating.", assignableRolePlace.getId(), assignableRolePlace.getMessageId());
|
||||||
return componentService.addButtonToMessage(assignableRolePlace.getMessageId(), textChannel, buttonId, description, emoteMarkdown, ButtonStyle.SECONDARY)
|
return messageService.editMessageInChannel(textChannel, messageToSend, assignableRolePlace.getMessageId()).thenAccept(unused -> {
|
||||||
.thenAccept(message -> self.persistAssignableRoleAddition(placeId, role, description, emoji, buttonId));
|
self.persistAssignableRoleAddition(placeId, role, description, emoji, buttonId);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
log.info("Assignable role place {} is not yet setup - only adding role to the database.", assignableRolePlace.getId());
|
log.info("Assignable role place {} is not yet setup - only adding role to the database.", assignableRolePlace.getId());
|
||||||
self.persistAssignableRoleAddition(placeId, role, description, emoji, buttonId);
|
self.persistAssignableRoleAddition(placeId, role, description, emoji, buttonId);
|
||||||
@@ -174,7 +179,7 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
return channelService.retrieveMessageInChannel(assignableRolePlace.getServer().getId(), assignableRolePlace.getChannel().getId(), assignableRolePlace.getMessageId())
|
return channelService.retrieveMessageInChannel(assignableRolePlace.getServer().getId(), assignableRolePlace.getChannel().getId(), assignableRolePlace.getMessageId())
|
||||||
.thenCompose(message -> {
|
.thenCompose(message -> {
|
||||||
log.debug("Updating message {} to remove component with ID {}.", message.getIdLong(), componentId);
|
log.debug("Updating message {} to remove component with ID {}.", message.getIdLong(), componentId);
|
||||||
return componentService.removeComponentWithId(message, componentId, true);
|
return componentService.removeComponentById(message, componentId).thenAccept(message1 -> {});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -269,8 +274,8 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
log.info("Deactivating assignable role place {} in server {}", place.getId(), place.getServer().getId());
|
log.info("Deactivating assignable role place {} in server {}", place.getId(), place.getServer().getId());
|
||||||
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
|
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
|
||||||
.thenCompose(message ->
|
.thenCompose(message ->
|
||||||
componentService.disableAllButtons(message)
|
componentService.disableAllComponents(message)
|
||||||
);
|
).thenAccept(message -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -283,8 +288,8 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
log.info("Activating assignable role place {} in server {}", place.getId(), place.getServer().getId());
|
log.info("Activating assignable role place {} in server {}", place.getId(), place.getServer().getId());
|
||||||
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
|
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
|
||||||
.thenCompose(message ->
|
.thenCompose(message ->
|
||||||
componentService.enableAllButtons(message)
|
componentService.enableAllComponents(message)
|
||||||
);
|
).thenAccept(message -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>assignable-roles-int</artifactId>
|
<artifactId>assignable-roles-int</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>entertainment</artifactId>
|
<artifactId>entertainment</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ public class TransferCredits extends AbstractConditionableCommand {
|
|||||||
.name(MEMBER_PARAMETER)
|
.name(MEMBER_PARAMETER)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.type(Member.class)
|
.type(Member.class)
|
||||||
.optional(true)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Parameter amountParameter = Parameter
|
Parameter amountParameter = Parameter
|
||||||
@@ -82,7 +81,6 @@ public class TransferCredits extends AbstractConditionableCommand {
|
|||||||
.name(AMOUNT_PARAMETER)
|
.name(AMOUNT_PARAMETER)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.type(Integer.class)
|
.type(Integer.class)
|
||||||
.optional(true)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<Parameter> parameters = Arrays.asList(memberParameter, amountParameter);
|
List<Parameter> parameters = Arrays.asList(memberParameter, amountParameter);
|
||||||
|
|||||||
@@ -200,8 +200,8 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
|||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageEmbedToSendToAChannel(messageToSend, pressF.getPressFChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageEmbedToSendToAChannel(messageToSend, pressF.getPressFChannel()))
|
||||||
.thenCompose(unused -> messageService.loadMessage(serverId, channelId, messageId).thenCompose(message -> {
|
.thenCompose(unused -> messageService.loadMessage(serverId, channelId, messageId).thenCompose(message -> {
|
||||||
log.info("Clearing buttons from pressF {} in with message {} in channel {} in server {}.", pressFId, pressFId, channelId, serverId);
|
log.info("Clearing buttons from pressF {} in with message {} in channel {} in server {}.", pressFId, pressFId, channelId, serverId);
|
||||||
return componentService.clearButtons(message);
|
return componentService.clearComponents(message);
|
||||||
}));
|
})).thenAccept(message -> {});
|
||||||
} else {
|
} else {
|
||||||
throw new AbstractoRunTimeException(String.format("PressF with id %s not found.", pressFId));
|
throw new AbstractoRunTimeException(String.format("PressF with id %s not found.", pressFId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>entertainment</artifactId>
|
<artifactId>entertainment</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>experience-tracking</artifactId>
|
<artifactId>experience-tracking</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -313,107 +313,107 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
|||||||
Long userInServerId = userInAServer.getUserInServerId();
|
Long userInServerId = userInAServer.getUserInServerId();
|
||||||
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
||||||
AUserExperience aUserExperience = aUserExperienceOptional.orElseGet(() -> userExperienceManagementService.createUserInServer(userInAServer));
|
AUserExperience aUserExperience = aUserExperienceOptional.orElseGet(() -> userExperienceManagementService.createUserInServer(userInAServer));
|
||||||
if(Boolean.FALSE.equals(aUserExperience.getExperienceGainDisabled())) {
|
if (aUserExperience.getExperienceGainDisabled().equals(Boolean.TRUE)) {
|
||||||
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 {
|
|
||||||
log.debug("Experience gain was disabled. User did not gain any experience.");
|
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) {
|
public LeaderBoardEntry getRankOfUserInServer(AUserInAServer userInAServer) {
|
||||||
log.debug("Retrieving rank for {}", userInAServer.getUserReference().getId());
|
log.debug("Retrieving rank for {}", userInAServer.getUserReference().getId());
|
||||||
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
Optional<AUserExperience> aUserExperienceOptional = userExperienceManagementService.findByUserInServerIdOptional(userInAServer.getUserInServerId());
|
||||||
if(!aUserExperienceOptional.isPresent()) {
|
if(aUserExperienceOptional.isEmpty()) {
|
||||||
throw new NoExperienceTrackedException();
|
throw new NoExperienceTrackedException();
|
||||||
}
|
}
|
||||||
Integer rank = 0;
|
Integer rank = 0;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class ExperienceLevelServiceBean implements ExperienceLevelService {
|
|||||||
if(level < 0) {
|
if(level < 0) {
|
||||||
throw new IllegalArgumentException("Level should not be less to 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
|
@Override
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class ExperienceRoleServiceBean implements ExperienceRoleService {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> unsetRoles(List<ARole> rolesToUnset, GuildMessageChannel messageChannel) {
|
public CompletableFuture<Void> unsetRoles(List<ARole> rolesToUnset, GuildMessageChannel messageChannel) {
|
||||||
List<AExperienceRole> rolesInServer = experienceRoleManagementService.getRolesInServer(rolesToUnset);
|
List<AExperienceRole> rolesInServer = experienceRoleManagementService.getRolesInServer(rolesToUnset);
|
||||||
Integer totalCount = 0;
|
int totalCount = 0;
|
||||||
for (AExperienceRole aExperienceRole : rolesInServer) {
|
for (AExperienceRole aExperienceRole : rolesInServer) {
|
||||||
totalCount += aExperienceRole.getUsers().size();
|
totalCount += aExperienceRole.getUsers().size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package dev.sheldan.abstracto.experience.service;
|
package dev.sheldan.abstracto.experience.service;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Getter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -17,11 +20,9 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
@Component
|
@Component
|
||||||
public class RunTimeExperienceService {
|
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();
|
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
|
* 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() {
|
public void cleanupRunTimeStorage() {
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
Set<Long> serverIdsToRemove = new HashSet<>();
|
||||||
runtimeExperience.forEach((serverId, userInstantMap) -> {
|
runtimeExperience.forEach((serverId, userInstantMap) -> {
|
||||||
List<Long> userIdsToRemove = new ArrayList<>();
|
List<Long> userIdsToRemove = new ArrayList<>();
|
||||||
userInstantMap.forEach((userId, instant) -> {
|
userInstantMap.forEach((userId, instant) -> {
|
||||||
@@ -47,6 +49,10 @@ public class RunTimeExperienceService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
userIdsToRemove.forEach(userInstantMap::remove);
|
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>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>experience-tracking</artifactId>
|
<artifactId>experience-tracking</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-impl</artifactId>
|
<artifactId>giveaway-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-int</artifactId>
|
<artifactId>giveaway-int</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-impl</artifactId>
|
<artifactId>image-generation-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-int</artifactId>
|
<artifactId>image-generation-int</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>invite-filter</artifactId>
|
<artifactId>invite-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>invite-filter</artifactId>
|
<artifactId>invite-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation-int</artifactId>
|
<artifactId>moderation-int</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>link-embed</artifactId>
|
<artifactId>link-embed</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<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.MessageCache;
|
||||||
import dev.sheldan.abstracto.core.service.MessageService;
|
import dev.sheldan.abstracto.core.service.MessageService;
|
||||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
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.config.LinkEmbedFeatureDefinition;
|
||||||
import dev.sheldan.abstracto.linkembed.model.MessageEmbedLink;
|
import dev.sheldan.abstracto.linkembed.model.MessageEmbedLink;
|
||||||
import dev.sheldan.abstracto.linkembed.service.MessageEmbedService;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.events.Event;
|
import net.dv8tion.jda.api.events.Event;
|
||||||
@@ -27,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -67,37 +70,51 @@ public class MessageEmbedListener implements MessageReceivedListener {
|
|||||||
}
|
}
|
||||||
String messageRaw = message.getContentRaw();
|
String messageRaw = message.getContentRaw();
|
||||||
List<MessageEmbedLink> links = messageEmbedService.getLinksInMessage(messageRaw);
|
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()) {
|
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());
|
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();
|
Long userEmbeddingUserInServerId = userInServerManagementService.loadOrCreateUser(message.getMember()).getUserInServerId();
|
||||||
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||||
for (MessageEmbedLink messageEmbedLink : links) {
|
for (MessageEmbedLink messageEmbedLink : links) {
|
||||||
// potentially support foreign linked servers
|
// potentially support foreign linked servers?
|
||||||
if(!messageEmbedLink.getServerId().equals(message.getGuild().getIdLong())) {
|
if(!messageEmbedLink.getServerId().equals(message.getGuild().getIdLong())) {
|
||||||
log.info("Link for message {} was from a foreign server {}. Do not embed.", messageEmbedLink.getMessageId(), messageEmbedLink.getServerId());
|
log.info("Link for message {} was from a foreign server {}. Do not embed.", messageEmbedLink.getMessageId(), messageEmbedLink.getServerId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
messageRaw = messageRaw.replace(messageEmbedLink.getWholeUrl(), "");
|
Function<CachedMessage, CompletableFuture<Void>> cachedMessageConsumer = cachedMessage -> self.embedSingleLink(message, userEmbeddingUserInServerId, cachedMessage);
|
||||||
Consumer<CachedMessage> cachedMessageConsumer = cachedMessage -> self.embedSingleLink(message, userEmbeddingUserInServerId, cachedMessage);
|
futures.add(messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
||||||
messageCache.getMessageFromCache(messageEmbedLink.getServerId(), messageEmbedLink.getChannelId(), messageEmbedLink.getMessageId())
|
.thenCompose(cachedMessageConsumer));
|
||||||
.thenAccept(cachedMessageConsumer)
|
}
|
||||||
.exceptionally(throwable -> {
|
if(!futures.isEmpty()) {
|
||||||
log.error("Error when embedding link for message {}", message.getId(), throwable);
|
// only delete the message if all futures go through
|
||||||
return null;
|
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()) {
|
if(deleteMessage) {
|
||||||
messageService.deleteMessage(message);
|
|
||||||
return ConsumableListenerResult.DELETED;
|
return ConsumableListenerResult.DELETED;
|
||||||
}
|
} else if(!links.isEmpty()) {
|
||||||
if(!links.isEmpty()) {
|
|
||||||
return ConsumableListenerResult.PROCESSED;
|
return ConsumableListenerResult.PROCESSED;
|
||||||
}
|
}
|
||||||
return ConsumableListenerResult.IGNORED;
|
return ConsumableListenerResult.IGNORED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void embedSingleLink(Message message, Long cause, CachedMessage cachedMessage) {
|
public CompletableFuture<Void> embedSingleLink(Message message, Long cause, CachedMessage cachedMessage) {
|
||||||
GuildMemberMessageChannel context = GuildMemberMessageChannel
|
GuildMemberMessageChannel context = GuildMemberMessageChannel
|
||||||
.builder()
|
.builder()
|
||||||
.guildChannel(message.getGuildChannel())
|
.guildChannel(message.getGuildChannel())
|
||||||
@@ -107,7 +124,7 @@ public class MessageEmbedListener implements MessageReceivedListener {
|
|||||||
.build();
|
.build();
|
||||||
log.info("Embedding link to message {} in channel {} in server {} to channel {} and server {}.",
|
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());
|
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)
|
metricService.incrementCounter(MESSAGE_EMBED_CREATED)
|
||||||
).exceptionally(throwable -> {
|
).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(),
|
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>
|
<parent>
|
||||||
<artifactId>link-embed</artifactId>
|
<artifactId>link-embed</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>logging</artifactId>
|
<artifactId>logging</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>logging</artifactId>
|
<artifactId>logging</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation</artifactId>
|
<artifactId>moderation</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
package dev.sheldan.abstracto.moderation.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
|
import dev.sheldan.abstracto.core.utils.ParseUtils;
|
||||||
|
import dev.sheldan.abstracto.moderation.config.ModerationModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.moderation.config.ModerationSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.moderation.config.feature.HoneyPotFeatureConfig;
|
||||||
|
import dev.sheldan.abstracto.moderation.config.feature.ModerationFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.moderation.listener.HoneyPotServiceBean;
|
||||||
|
import dev.sheldan.abstracto.moderation.model.template.command.HoneyPotBanResponseModel;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class HoneyPotBan extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String DURATION_PARAMETER = "duration";
|
||||||
|
private static final String HONEYPOT_BAN_RESPONSE = "honeypotBan_response";
|
||||||
|
private static final String HONEYPOT_BAN_COMMAND = "honeypotBan";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HoneyPotBan self;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HoneyPotServiceBean honeyPotServiceBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfigService configService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
Duration duration;
|
||||||
|
if(slashCommandParameterService.hasCommandOption(DURATION_PARAMETER, event)) {
|
||||||
|
String durationStr = slashCommandParameterService.getCommandOption(DURATION_PARAMETER, event, Duration.class, String.class);
|
||||||
|
duration = ParseUtils.parseDuration(durationStr);
|
||||||
|
} else {
|
||||||
|
Long ignoredSeconds =
|
||||||
|
configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_IGNORED_JOIN_DURATION_SECONDS, event.getGuild().getIdLong());
|
||||||
|
duration = Duration.ofSeconds(ignoredSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return event.deferReply(false).submit()
|
||||||
|
.thenCompose(hook -> self.banEveryHoneypotMember(hook, event.getGuild(), duration))
|
||||||
|
.thenCompose(banResponse -> self.sendResponse(banResponse))
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public CompletableFuture<Void> sendResponse(Pair<InteractionHook, Integer> banResponse) {
|
||||||
|
HoneyPotBanResponseModel responseModel = HoneyPotBanResponseModel
|
||||||
|
.builder()
|
||||||
|
.bannedMemberCount(banResponse.getRight())
|
||||||
|
.build();
|
||||||
|
return FutureUtils.toSingleFutureGeneric(interactionService.sendMessageToInteraction(HONEYPOT_BAN_RESPONSE, responseModel, banResponse.getLeft()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public CompletableFuture<Pair<InteractionHook, Integer>> banEveryHoneypotMember(InteractionHook hook, Guild guild, Duration duration) {
|
||||||
|
Instant maxJoinAge;
|
||||||
|
if(duration != null) {
|
||||||
|
maxJoinAge = Instant.now().minus(duration);
|
||||||
|
} else {
|
||||||
|
maxJoinAge = Instant.now();
|
||||||
|
}
|
||||||
|
List<Member> currentMembersWithHoneypotRole = honeyPotServiceBean.getCurrentMembersWithHoneypotRole(guild)
|
||||||
|
.stream().filter(member -> member.getTimeJoined().toInstant().isBefore(maxJoinAge))
|
||||||
|
.toList();
|
||||||
|
Role honeyPotRole = guild.getRoleById(honeyPotServiceBean.getHoneyPotRoleId(guild.getIdLong()));
|
||||||
|
List<CompletableFuture<Void>> futures = currentMembersWithHoneypotRole.stream().map(member ->
|
||||||
|
honeyPotServiceBean.banForHoneyPot(member, honeyPotRole)
|
||||||
|
).toList();
|
||||||
|
Integer memberCount = currentMembersWithHoneypotRole.size();
|
||||||
|
CompletableFutureList<Void> futureList = new CompletableFutureList<>(futures);
|
||||||
|
return futureList.getMainFuture()
|
||||||
|
.thenApply(unused -> Pair.of(hook, memberCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
|
||||||
|
Parameter durationParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(DURATION_PARAMETER)
|
||||||
|
.templated(true)
|
||||||
|
.type(String.class)
|
||||||
|
.optional(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(durationParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.hasExample(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(ModerationSlashCommandNames.MODERATION)
|
||||||
|
.defaultPrivilege(SlashCommandPrivilegeLevels.INVITER)
|
||||||
|
.commandName("honeypotban")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(HONEYPOT_BAN_COMMAND)
|
||||||
|
.module(ModerationModuleDefinition.MODERATION)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return ModerationFeatureDefinition.HONEYPOT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,7 +61,7 @@ public class BanModerationActionModalListener implements ModalInteractionListene
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getDurationInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getDurationInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
@@ -76,7 +76,7 @@ public class BanModerationActionModalListener implements ModalInteractionListene
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getReasonInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getReasonInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -4,97 +4,44 @@ import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
|||||||
import dev.sheldan.abstracto.core.config.ListenerPriority;
|
import dev.sheldan.abstracto.core.config.ListenerPriority;
|
||||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||||
import dev.sheldan.abstracto.core.listener.sync.jda.RoleAddedListener;
|
import dev.sheldan.abstracto.core.listener.sync.jda.RoleAddedListener;
|
||||||
import dev.sheldan.abstracto.core.models.ConditionContextInstance;
|
|
||||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
|
||||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
|
||||||
import dev.sheldan.abstracto.core.models.listener.RoleAddedModel;
|
import dev.sheldan.abstracto.core.models.listener.RoleAddedModel;
|
||||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
|
|
||||||
import dev.sheldan.abstracto.core.service.ConditionService;
|
|
||||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
|
||||||
import dev.sheldan.abstracto.core.service.RoleService;
|
import dev.sheldan.abstracto.core.service.RoleService;
|
||||||
import dev.sheldan.abstracto.core.service.SystemCondition;
|
|
||||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
|
||||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
|
||||||
import dev.sheldan.abstracto.moderation.config.feature.HoneyPotFeatureConfig;
|
|
||||||
import dev.sheldan.abstracto.moderation.config.feature.ModerationFeatureDefinition;
|
import dev.sheldan.abstracto.moderation.config.feature.ModerationFeatureDefinition;
|
||||||
import dev.sheldan.abstracto.moderation.model.listener.HoneyPotReasonModel;
|
|
||||||
import dev.sheldan.abstracto.moderation.service.BanService;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.entities.ISnowflake;
|
import net.dv8tion.jda.api.entities.ISnowflake;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HoneyPotRoleAddedListener implements RoleAddedListener {
|
public class HoneyPotRoleAddedListener implements RoleAddedListener {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ConfigService configService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BanService banService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TemplateService templateService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ConditionService conditionService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserInServerManagementService userInServerManagementService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
private static final String HONEYPOT_BAN_REASON_TEMPLATE = "honeypot_ban_reason";
|
@Autowired
|
||||||
|
private HoneyPotServiceBean honeyPotServiceBean;
|
||||||
private static final String LEVEL_CONDITION_USER_ID_PARAMETER = "userId";
|
|
||||||
private static final String LEVEL_CONDITION_LEVEL_PARAMETER = "level";
|
|
||||||
private static final String LEVEL_CONDITION_SERVER_PARAMETER = "serverId";
|
|
||||||
|
|
||||||
private static final String LEVEL_CONDITION_NAME = "HAS_LEVEL";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultListenerResult execute(RoleAddedModel model) {
|
public DefaultListenerResult execute(RoleAddedModel model) {
|
||||||
Long honeyPotRoleId = configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_ROLE_ID, model.getServerId());
|
Long honeyPotRoleId = honeyPotServiceBean.getHoneyPotRoleId(model.getServerId());
|
||||||
if(honeyPotRoleId == 0) {
|
if(honeyPotRoleId == 0) {
|
||||||
log.info("Server {} has honeypot feature enabled, but still default honeypot role config - Ignoring.", model.getServerId());
|
log.info("Server {} has honeypot feature enabled, but still default honeypot role config - Ignoring.", model.getServerId());
|
||||||
return DefaultListenerResult.IGNORED;
|
return DefaultListenerResult.IGNORED;
|
||||||
}
|
}
|
||||||
if(honeyPotRoleId.equals(model.getRoleId())) {
|
if(honeyPotRoleId.equals(model.getRoleId())) {
|
||||||
Integer levelToSkipBan = configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_IGNORED_LEVEL, model.getServerId()).intValue();
|
boolean fellIntoHoneyPot = honeyPotServiceBean.fellIntoHoneyPot(model.getServerId(), model.getTargetMember());
|
||||||
Long amountOfSecondsToIgnore = configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_IGNORED_JOIN_DURATION_SECONDS, model.getServerId());
|
if (fellIntoHoneyPot) {
|
||||||
boolean allowed = userHasLevel(model.getTargetMember(), levelToSkipBan) || userJoinedLongerThanSeconds(model.getTargetMember(), amountOfSecondsToIgnore);
|
|
||||||
if(allowed) {
|
|
||||||
log.info("User {} in server {} has at least level {} or joined more than {} seconds ago and will not get banned by honeypot. All existing roles besides {} will be removed.",
|
|
||||||
model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), levelToSkipBan, amountOfSecondsToIgnore, honeyPotRoleId);
|
|
||||||
cleanupRolesBesidesHoneyPot(model, honeyPotRoleId);
|
|
||||||
} else {
|
|
||||||
log.info("Banning user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId());
|
log.info("Banning user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId());
|
||||||
HoneyPotReasonModel reasonModel = HoneyPotReasonModel
|
honeyPotServiceBean.banForHoneyPot(model.getTargetMember(), model.getRole());
|
||||||
.builder()
|
} else {
|
||||||
.memberDisplay(MemberDisplay.fromMember(model.getTargetMember()))
|
log.info("User {} in server {} will not get banned by honeypot. All existing roles besides {} will be removed.",
|
||||||
.roleDisplay(RoleDisplay.fromRole(model.getRole()))
|
model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), honeyPotRoleId);
|
||||||
.build();
|
cleanupRolesBesidesHoneyPot(model, honeyPotRoleId);
|
||||||
String banReason = templateService.renderTemplate(HONEYPOT_BAN_REASON_TEMPLATE, reasonModel, model.getServerId());
|
|
||||||
banService.banUserWithNotification(model.getTargetUser(), banReason, ServerUser.fromMember(model.getTargetMember().getGuild().getSelfMember()),
|
|
||||||
model.getTargetMember().getGuild(), Duration.ofDays(7)).thenAccept(banResult -> {
|
|
||||||
log.info("Banned user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId());
|
|
||||||
}).exceptionally(throwable -> {
|
|
||||||
log.error("Failed to ban user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId(), throwable);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return DefaultListenerResult.PROCESSED;
|
return DefaultListenerResult.PROCESSED;
|
||||||
} else {
|
} else {
|
||||||
@@ -126,28 +73,6 @@ public class HoneyPotRoleAddedListener implements RoleAddedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean userHasLevel(Member member, Integer level) {
|
|
||||||
log.info("Checking if member {} is ignored to click on the honeypot in server {}.", member.getIdLong(),member.getGuild().getIdLong());
|
|
||||||
Map<String, Object> parameters = new HashMap<>();
|
|
||||||
AUserInAServer userInAServer = userInServerManagementService.loadOrCreateUser(member);
|
|
||||||
parameters.put(LEVEL_CONDITION_USER_ID_PARAMETER, userInAServer.getUserInServerId());
|
|
||||||
parameters.put(LEVEL_CONDITION_LEVEL_PARAMETER, level);
|
|
||||||
parameters.put(LEVEL_CONDITION_SERVER_PARAMETER, member.getGuild().getIdLong());
|
|
||||||
ConditionContextInstance contextInstance = ConditionContextInstance
|
|
||||||
.builder()
|
|
||||||
.conditionName(LEVEL_CONDITION_NAME)
|
|
||||||
.parameters(parameters)
|
|
||||||
.build();
|
|
||||||
SystemCondition.Result result = conditionService.checkConditions(contextInstance);
|
|
||||||
return SystemCondition.Result.isSuccessful(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean userJoinedLongerThanSeconds(Member member, Long seconds) {
|
|
||||||
log.info("Checking if member {} joined the server more than {} seconds ago.", member.getIdLong(), seconds);
|
|
||||||
// the incorrectness of timejoined should not matter, we chunk anyway
|
|
||||||
return member.getTimeJoined().toInstant().isBefore(Instant.now().minus(seconds, ChronoUnit.SECONDS));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FeatureDefinition getFeature() {
|
public FeatureDefinition getFeature() {
|
||||||
return ModerationFeatureDefinition.HONEYPOT;
|
return ModerationFeatureDefinition.HONEYPOT;
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package dev.sheldan.abstracto.moderation.listener;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.ConditionContextInstance;
|
||||||
|
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
|
||||||
|
import dev.sheldan.abstracto.core.service.ConditionService;
|
||||||
|
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||||
|
import dev.sheldan.abstracto.core.service.MemberService;
|
||||||
|
import dev.sheldan.abstracto.core.service.SystemCondition;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.moderation.config.feature.HoneyPotFeatureConfig;
|
||||||
|
import dev.sheldan.abstracto.moderation.model.listener.HoneyPotReasonModel;
|
||||||
|
import dev.sheldan.abstracto.moderation.service.BanService;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class HoneyPotServiceBean {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConditionService conditionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BanService banService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
private static final String LEVEL_CONDITION_USER_ID_PARAMETER = "userId";
|
||||||
|
private static final String LEVEL_CONDITION_LEVEL_PARAMETER = "level";
|
||||||
|
private static final String LEVEL_CONDITION_SERVER_PARAMETER = "serverId";
|
||||||
|
private static final String LEVEL_CONDITION_NAME = "HAS_LEVEL";
|
||||||
|
private static final String HONEYPOT_BAN_REASON_TEMPLATE = "honeypot_ban_reason";
|
||||||
|
|
||||||
|
|
||||||
|
public Long getHoneyPotRoleId(Long serverId) {
|
||||||
|
return configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_ROLE_ID, serverId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fellIntoHoneyPot(Long serverId, Member member) {
|
||||||
|
Integer levelToSkipBan = configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_IGNORED_LEVEL, serverId).intValue();
|
||||||
|
Long amountOfSecondsToIgnore = configService.getLongValueOrConfigDefault(HoneyPotFeatureConfig.HONEYPOT_IGNORED_JOIN_DURATION_SECONDS, serverId);
|
||||||
|
boolean allowed = userHasLevel(member, levelToSkipBan) || userJoinedLongerThanSeconds(member, amountOfSecondsToIgnore);
|
||||||
|
return !allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Member> getCurrentMembersWithHoneypotRole(Guild guild) {
|
||||||
|
return memberService.getMembersWithRole(guild.getIdLong(), getHoneyPotRoleId(guild.getIdLong()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> banForHoneyPot(Member targetMember, Role role) {
|
||||||
|
HoneyPotReasonModel reasonModel = HoneyPotReasonModel
|
||||||
|
.builder()
|
||||||
|
.memberDisplay(MemberDisplay.fromMember(targetMember))
|
||||||
|
.roleDisplay(RoleDisplay.fromRole(role))
|
||||||
|
.build();
|
||||||
|
ServerUser bannedUser = ServerUser.fromMember(targetMember);
|
||||||
|
String banReason = templateService.renderTemplate(HONEYPOT_BAN_REASON_TEMPLATE, reasonModel, bannedUser.getServerId());
|
||||||
|
long roleId = role.getIdLong();
|
||||||
|
return banService.banUserWithNotification(bannedUser, banReason, ServerUser.fromMember(targetMember.getGuild().getSelfMember()),
|
||||||
|
targetMember.getGuild(), Duration.ofDays(7)).thenAccept(banResult -> {
|
||||||
|
log.info("Banned user {} in guild {} due to role {}.", bannedUser.getUserId(), bannedUser.getServerId(), roleId);
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to ban user {} in guild {} due to role {}.", bannedUser.getUserId(), bannedUser.getServerId(), roleId, throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean userHasLevel(Member member, Integer level) {
|
||||||
|
log.info("Checking if member {} is ignored to click on the honeypot in server {}.", member.getIdLong(),member.getGuild().getIdLong());
|
||||||
|
Map<String, Object> parameters = new HashMap<>();
|
||||||
|
AUserInAServer userInAServer = userInServerManagementService.loadOrCreateUser(member);
|
||||||
|
parameters.put(LEVEL_CONDITION_USER_ID_PARAMETER, userInAServer.getUserInServerId());
|
||||||
|
parameters.put(LEVEL_CONDITION_LEVEL_PARAMETER, level);
|
||||||
|
parameters.put(LEVEL_CONDITION_SERVER_PARAMETER, member.getGuild().getIdLong());
|
||||||
|
ConditionContextInstance contextInstance = ConditionContextInstance
|
||||||
|
.builder()
|
||||||
|
.conditionName(LEVEL_CONDITION_NAME)
|
||||||
|
.parameters(parameters)
|
||||||
|
.build();
|
||||||
|
SystemCondition.Result result = conditionService.checkConditions(contextInstance);
|
||||||
|
return SystemCondition.Result.isSuccessful(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean userJoinedLongerThanSeconds(Member member, Long seconds) {
|
||||||
|
log.info("Checking if member {} joined the server more than {} seconds ago.", member.getIdLong(), seconds);
|
||||||
|
// the incorrectness of timejoined should not matter, we chunk anyway
|
||||||
|
return member.getTimeJoined().toInstant().isBefore(Instant.now().minus(seconds, ChronoUnit.SECONDS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -51,7 +51,7 @@ public class KickModerationActionModalListener implements ModalInteractionListen
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getReasonInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getReasonInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class MuteModerationActionModalListener implements ModalInteractionListen
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getReasonInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getReasonInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
@@ -68,7 +68,7 @@ public class MuteModerationActionModalListener implements ModalInteractionListen
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getDurationInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getDurationInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class WarnModerationActionModalListener implements ModalInteractionListen
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getReasonInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getReasonInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class ReportContextModalListener implements ModalInteractionListener {
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getTextInputId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getTextInputId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ public class KickServiceBean implements KickService {
|
|||||||
public CompletableFuture<Void> kickMember(Member kickedMember, Member kickingMember, String reason) {
|
public CompletableFuture<Void> kickMember(Member kickedMember, Member kickingMember, String reason) {
|
||||||
Guild guild = kickedMember.getGuild();
|
Guild guild = kickedMember.getGuild();
|
||||||
log.info("Kicking user {} from guild {}", kickedMember.getUser().getIdLong(), guild.getIdLong());
|
log.info("Kicking user {} from guild {}", kickedMember.getUser().getIdLong(), guild.getIdLong());
|
||||||
CompletableFuture<Void> kickFuture = guild.kick(kickedMember, reason).submit();
|
CompletableFuture<Void> kickFuture = guild.kick(kickedMember)
|
||||||
|
.reason(reason)
|
||||||
|
.submit();
|
||||||
CompletableFuture<Message> logFuture = sendKickLog(kickedMember.getUser(), ServerUser.fromMember(kickedMember), kickingMember.getUser(), ServerUser.fromMember(kickingMember), reason, guild.getIdLong());
|
CompletableFuture<Message> logFuture = sendKickLog(kickedMember.getUser(), ServerUser.fromMember(kickedMember), kickingMember.getUser(), ServerUser.fromMember(kickingMember), reason, guild.getIdLong());
|
||||||
return CompletableFuture.allOf(kickFuture, logFuture)
|
return CompletableFuture.allOf(kickFuture, logFuture)
|
||||||
.thenAccept(unused -> self.storeInfraction(kickedMember, kickingMember, reason, logFuture.join(), guild.getIdLong()));
|
.thenAccept(unused -> self.storeInfraction(kickedMember, kickingMember, reason, logFuture.join(), guild.getIdLong()));
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<property name="moderationModule" value="(SELECT id FROM module WHERE name = 'moderation')"/>
|
||||||
|
<property name="honeypotFeature" value="(SELECT id FROM feature WHERE key = 'honeypot')"/>
|
||||||
|
|
||||||
|
<changeSet author="Sheldan" id="honeypotBan-command">
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="honeypotBan"/>
|
||||||
|
<column name="module_id" valueComputed="${moderationModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${honeypotFeature}"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -13,4 +13,5 @@
|
|||||||
<include file="1.4.3/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.3/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.5.10/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.5.10/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.5.23/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.5.23/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="1.6.21/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation</artifactId>
|
<artifactId>moderation</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.sheldan.abstracto.moderation.model.template.command;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class HoneyPotBanResponseModel {
|
||||||
|
private Integer bannedMemberCount;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>modmail</artifactId>
|
<artifactId>modmail</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>modmail</artifactId>
|
<artifactId>modmail</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto</groupId>
|
<groupId>dev.sheldan.abstracto</groupId>
|
||||||
<artifactId>abstracto-application</artifactId>
|
<artifactId>abstracto-application</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>profanity-filter</artifactId>
|
<artifactId>profanity-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>profanity-filter</artifactId>
|
<artifactId>profanity-filter</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>remind</artifactId>
|
<artifactId>remind</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -130,13 +130,14 @@ public class RemindServiceBean implements ReminderService {
|
|||||||
if(remindIn.getSeconds() < 60) {
|
if(remindIn.getSeconds() < 60) {
|
||||||
reminder.setJobTriggerKey(null);
|
reminder.setJobTriggerKey(null);
|
||||||
log.info("Directly scheduling unremind for reminder {}, because it was below the threshold.", reminder.getId());
|
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(() -> {
|
instantReminderScheduler.schedule(() -> {
|
||||||
try {
|
try {
|
||||||
self.executeReminder(reminder.getId());
|
self.executeReminder(reminder.getId());
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
log.error("Failed to remind immediately.", exception);
|
log.error("Failed to remind immediately.", exception);
|
||||||
}
|
}
|
||||||
}, remindIn.toNanos(), TimeUnit.NANOSECONDS);
|
}, nanos, TimeUnit.NANOSECONDS);
|
||||||
} else {
|
} else {
|
||||||
HashMap<Object, Object> parameters = new HashMap<>();
|
HashMap<Object, Object> parameters = new HashMap<>();
|
||||||
parameters.put("reminderId", reminder.getId().toString());
|
parameters.put("reminderId", reminder.getId().toString());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>remind</artifactId>
|
<artifactId>remind</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>repost-detection</artifactId>
|
<artifactId>repost-detection</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>repost-detection</artifactId>
|
<artifactId>repost-detection</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>starboard</artifactId>
|
<artifactId>starboard</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>starboard</artifactId>
|
<artifactId>starboard</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>statistic</artifactId>
|
<artifactId>statistic</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>statistic</artifactId>
|
<artifactId>statistic</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>sticky-roles</artifactId>
|
<artifactId>sticky-roles</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-impl</artifactId>
|
<artifactId>sticky-roles-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>sticky-roles</artifactId>
|
<artifactId>sticky-roles</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-int</artifactId>
|
<artifactId>sticky-roles-int</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>suggestion</artifactId>
|
<artifactId>suggestion</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ServerPollAddOptionModalListener implements ModalInteractionListene
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getLabelInputComponentId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getLabelInputComponentId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
@@ -62,7 +62,7 @@ public class ServerPollAddOptionModalListener implements ModalInteractionListene
|
|||||||
.getEvent()
|
.getEvent()
|
||||||
.getValues()
|
.getValues()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(modalMapping -> modalMapping.getId().equals(payload.getDescriptionInputComponentId()))
|
.filter(modalMapping -> modalMapping.getCustomId().equals(payload.getDescriptionInputComponentId()))
|
||||||
.map(ModalMapping::getAsString)
|
.map(ModalMapping::getAsString)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
if(useButtons) {
|
if(useButtons) {
|
||||||
return messageService.loadMessage(serverId, channelId, messageId).thenCompose(message -> {
|
return messageService.loadMessage(serverId, channelId, messageId).thenCompose(message -> {
|
||||||
log.info("Clearing buttons from suggestion {} in with message {} in channel {} in server {}.", suggestionId, message, channelId, serverId);
|
log.info("Clearing buttons from suggestion {} in with message {} in channel {} in server {}.", suggestionId, message, channelId, serverId);
|
||||||
return componentService.clearButtons(message);
|
return componentService.clearComponents(message);
|
||||||
});
|
}).thenAccept(message -> {});
|
||||||
} else {
|
} else {
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>suggestion</artifactId>
|
<artifactId>suggestion</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>twitch</artifactId>
|
<artifactId>twitch</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>twitch</artifactId>
|
<artifactId>twitch</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>twitch-int</artifactId>
|
<artifactId>twitch-int</artifactId>
|
||||||
@@ -14,11 +15,10 @@
|
|||||||
<groupId>com.github.twitch4j</groupId>
|
<groupId>com.github.twitch4j</groupId>
|
||||||
<artifactId>twitch4j</artifactId>
|
<artifactId>twitch4j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.apollographql.apollo</groupId>
|
||||||
|
<artifactId>apollo-runtime</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>utility</artifactId>
|
<artifactId>utility</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>utility</artifactId>
|
<artifactId>utility</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>voice-channel-context</artifactId>
|
<artifactId>voice-channel-context</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>voice-channel-context</artifactId>
|
<artifactId>voice-channel-context</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>webservices</artifactId>
|
<artifactId>webservices</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>webservices</artifactId>
|
<artifactId>webservices</artifactId>
|
||||||
<version>1.6.18</version>
|
<version>1.6.21</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user