mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-27 06:04:54 +00:00
moved post targets to an enum, in order to have more type safety, this might be changed in the future
added validation check when a feature is enabled, in order to notify which configuration is missing for this feature to function properly
This commit is contained in:
@@ -5,8 +5,8 @@ import dev.sheldan.abstracto.core.listener.MessageReceivedListener;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.service.MessageCache;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
import dev.sheldan.abstracto.utility.models.MessageEmbedLink;
|
||||
import dev.sheldan.abstracto.utility.config.features.UtilityFeature;
|
||||
import dev.sheldan.abstracto.utility.models.MessageEmbedLink;
|
||||
import dev.sheldan.abstracto.utility.service.MessageEmbedService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
@@ -15,6 +15,7 @@ import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.config.StarboardConfig;
|
||||
import dev.sheldan.abstracto.utility.config.posttargets.StarboardPostTarget;
|
||||
import dev.sheldan.abstracto.utility.models.database.StarboardPost;
|
||||
import dev.sheldan.abstracto.utility.models.template.commands.starboard.StarStatsModel;
|
||||
import dev.sheldan.abstracto.utility.models.template.commands.starboard.StarStatsPost;
|
||||
@@ -40,7 +41,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class StarboardServiceBean implements StarboardService {
|
||||
|
||||
public static final String STARBOARD_POSTTARGET = "starboard";
|
||||
public static final String STARBOARD_POST_TEMPLATE = "starboard_post";
|
||||
|
||||
@Autowired
|
||||
@@ -87,8 +87,8 @@ public class StarboardServiceBean implements StarboardService {
|
||||
userExceptAuthorIds.add(aUserInAServer.getUserInServerId());
|
||||
});
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(STARBOARD_POST_TEMPLATE, starboardPostModel);
|
||||
PostTarget starboard = postTargetManagement.getPostTarget(STARBOARD_POSTTARGET, message.getServerId());
|
||||
List<CompletableFuture<Message>> completableFutures = postTargetService.sendEmbedInPostTarget(messageToSend, STARBOARD_POSTTARGET, message.getServerId());
|
||||
PostTarget starboard = postTargetManagement.getPostTarget(StarboardPostTarget.STARBOARD.getKey(), message.getServerId());
|
||||
List<CompletableFuture<Message>> completableFutures = postTargetService.sendEmbedInPostTarget(messageToSend, StarboardPostTarget.STARBOARD, message.getServerId());
|
||||
Long starboardChannelId = starboard.getChannelReference().getId();
|
||||
Long starredUserId = starredUser.getUserInServerId();
|
||||
Long userReactingId = userReacting.getUserInServerId();
|
||||
@@ -152,7 +152,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(STARBOARD_POST_TEMPLATE, starboardPostModel);
|
||||
List<CompletableFuture<Message>> futures = new ArrayList<>();
|
||||
futures.add(new CompletableFuture<>());
|
||||
postTargetService.editOrCreatedInPostTarget(post.getStarboardMessageId(), messageToSend, STARBOARD_POSTTARGET, message.getServerId(), futures);
|
||||
postTargetService.editOrCreatedInPostTarget(post.getStarboardMessageId(), messageToSend, StarboardPostTarget.STARBOARD, message.getServerId(), futures);
|
||||
Long starboardPostId = post.getId();
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenAccept(aVoid -> {
|
||||
try {
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||
import dev.sheldan.abstracto.core.utils.MessageUtils;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.config.posttargets.SuggestionPostTarget;
|
||||
import dev.sheldan.abstracto.utility.exception.SuggestionNotFoundException;
|
||||
import dev.sheldan.abstracto.utility.models.database.Suggestion;
|
||||
import dev.sheldan.abstracto.utility.models.SuggestionState;
|
||||
@@ -32,7 +33,6 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
public static final String SUGGESTION_LOG_TEMPLATE = "suggest_log";
|
||||
private static final String SUGGESTION_YES_EMOTE = "suggestionYes";
|
||||
private static final String SUGGESTION_NO_EMOTE = "suggestionNo";
|
||||
public static final String SUGGESTIONS_TARGET = "suggestions";
|
||||
|
||||
@Autowired
|
||||
private SuggestionManagementService suggestionManagementService;
|
||||
@@ -63,7 +63,7 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
JDA instance = botService.getInstance();
|
||||
Guild guildById = instance.getGuildById(guildId);
|
||||
if(guildById != null) {
|
||||
List<CompletableFuture<Message>> completableFutures = postTargetService.sendEmbedInPostTarget(messageToSend, SUGGESTIONS_TARGET, guildId);
|
||||
List<CompletableFuture<Message>> completableFutures = postTargetService.sendEmbedInPostTarget(messageToSend, SuggestionPostTarget.SUGGESTION, guildId);
|
||||
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).thenAccept(aVoid -> {
|
||||
Suggestion innerSuggestion = suggestionManagementService.getSuggestion(suggestionId).orElseThrow(() -> new SuggestionNotFoundException(suggestionId));
|
||||
try {
|
||||
@@ -124,7 +124,7 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
suggestionLog.setReason(text);
|
||||
suggestionLog.setText(suggestionEmbed.getDescription());
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SUGGESTION_LOG_TEMPLATE, suggestionLog);
|
||||
postTargetService.sendEmbedInPostTarget(messageToSend, SUGGESTIONS_TARGET, suggestionLog.getServer().getId());
|
||||
postTargetService.sendEmbedInPostTarget(messageToSend, SuggestionPostTarget.SUGGESTION, suggestionLog.getServer().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,6 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
|
||||
@Override
|
||||
public void validateSetup(Long serverId) {
|
||||
postTargetService.throwIfPostTargetIsNotDefined(SUGGESTIONS_TARGET, serverId);
|
||||
postTargetService.throwIfPostTargetIsNotDefined(SuggestionPostTarget.SUGGESTION, serverId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user