mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 03:45:57 +00:00
added mechanism to dynamically load properties defining postTargets and valid emoteNames
changed the output of the exception message refactored emote management service added service to define whether or not an emote is usable by the bot
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.abstracto.utility.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:utility.properties")
|
||||
public class UtilityConfig {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.utility.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.management.EmoteManagementService;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
||||
import dev.sheldan.abstracto.core.service.Bot;
|
||||
import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||
@@ -24,8 +23,9 @@ import org.springframework.stereotype.Component;
|
||||
public class SuggestionServiceBean implements SuggestionService {
|
||||
|
||||
public static final String SUGGESTION_LOG_TEMPLATE = "suggest_log";
|
||||
public static final String SUGGESTION_YES_EMOTE = "SUGGESTION_YES";
|
||||
public static final String SUGGESTION_NO_EMOTE = "SUGGESTION_NO";
|
||||
private static final String SUGGESTION_YES_EMOTE = "SUGGESTION_YES";
|
||||
private static final String SUGGESTION_NO_EMOTE = "SUGGESTION_NO";
|
||||
public static final String SUGGESTIONS_TARGET = "suggestions";
|
||||
@Autowired
|
||||
private SuggestionManagementService suggestionManagementService;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
JDA instance = botService.getInstance();
|
||||
Guild guildById = instance.getGuildById(guildId);
|
||||
if(guildById != null) {
|
||||
postTargetService.sendEmbedInPostTarget(embed, PostTarget.SUGGESTIONS, guildId).thenAccept(message -> {
|
||||
postTargetService.sendEmbedInPostTarget(embed, SUGGESTIONS_TARGET, guildId).thenAccept(message -> {
|
||||
messageService.addReactionToMessage(SUGGESTION_YES_EMOTE, guildId, message);
|
||||
messageService.addReactionToMessage(SUGGESTION_NO_EMOTE, guildId, message);
|
||||
suggestionManagementService.setPostedMessage(suggestion, message);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.sheldan.abstracto.utility.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
||||
import dev.sheldan.abstracto.core.service.PostTargetService;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import dev.sheldan.abstracto.utility.models.template.SuggestionLog;
|
||||
@@ -15,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Optional;
|
||||
|
||||
import static dev.sheldan.abstracto.utility.service.SuggestionServiceBean.SUGGESTION_LOG_TEMPLATE;
|
||||
import static dev.sheldan.abstracto.utility.service.SuggestionServiceBean.SUGGESTIONS_TARGET;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -34,7 +34,7 @@ public class AsyncSuggestionServiceBean {
|
||||
suggestionLog.setReason(text);
|
||||
suggestionLog.setText(suggestionEmbed.getDescription());
|
||||
MessageEmbed embed = templateService.renderEmbedTemplate(SUGGESTION_LOG_TEMPLATE, suggestionLog);
|
||||
postTargetService.sendEmbedInPostTarget(embed, PostTarget.SUGGESTIONS, suggestionLog.getServer().getId());
|
||||
postTargetService.sendEmbedInPostTarget(embed, SUGGESTIONS_TARGET, suggestionLog.getServer().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
abstracto.postTargets.utility=suggestions
|
||||
@@ -0,0 +1,2 @@
|
||||
abstracto.postTargets.utility=suggestions
|
||||
abstracto.emoteNames.suggestion=SUGGESTION_YES,SUGGESTION_NO
|
||||
Reference in New Issue
Block a user