added configurable warning and success reactions

changed that channels dont actually get deleted, but rather with a deleted flag, so the foreign keys are valid
added more optionals to server/channel/message/member retrieval
added throwing exceptions instead of just returning null
fixed filtering of deleted channels while the bot was offline
fixed channel listener
added message deleted listener structure
moved quartz properties to general application properties, because they were not found in the separate one
added try catch to reminderJob, so that the job is not in an invalid state
we now completely remove the starboard post, in case it falls under the threshold
added code to 'ignore' a staroard post form further stars, in case the post in the starboard gets deleted
now actually setting the reminded flag on a reminder
added handnling in case the channel to remind in does not exist anymore
This commit is contained in:
Sheldan
2020-04-01 23:46:28 +02:00
parent 089862bf15
commit c9557fccc2
45 changed files with 409 additions and 181 deletions

View File

@@ -29,7 +29,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Nonnull;
import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class CommandReceivedHandler extends ListenerAdapter {
@@ -91,7 +90,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
private UserInitiatedServerContext buildTemplateParameter(MessageReceivedEvent event) {
AChannel channel = channelManagementService.loadChannel(event.getChannel().getIdLong());
AServer server = serverManagementService.loadServer(event.getGuild().getIdLong());
AServer server = serverManagementService.loadOrCreate(event.getGuild().getIdLong());
AUserInAServer user = userManagementService.loadUser(event.getMember());
return UserInitiatedServerContext
.builder()

View File

@@ -0,0 +1,10 @@
package dev.sheldan.abstracto.commands.management.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:commands.properties")
public class CommandConfig {
}

View File

@@ -5,20 +5,28 @@ import dev.sheldan.abstracto.command.PostCommandExecution;
import dev.sheldan.abstracto.command.execution.CommandContext;
import dev.sheldan.abstracto.command.execution.Result;
import dev.sheldan.abstracto.command.execution.ResultState;
import dev.sheldan.abstracto.core.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ReactionPostExecution implements PostCommandExecution {
public static final String WARN_REACTION_EMOTE = "warnReaction";
public static final String SUCCESS_REACTION_EMOTE = "successReaction";
@Autowired
private MessageService messageService;
@Override
public void execute(CommandContext commandContext, Result result, Command command) {
if(result.getResult().equals(ResultState.ERROR)) {
commandContext.getMessage().addReaction("⚠️").queue();
messageService.addReactionToMessage(WARN_REACTION_EMOTE, commandContext.getGuild().getIdLong(), commandContext.getMessage());
if(result.getMessage() != null && result.getThrowable() == null){
commandContext.getChannel().sendMessage(result.getMessage()).queue();
}
} else {
if(command.getConfiguration().isCausesReaction()){
commandContext.getMessage().addReaction("").queue();
messageService.addReactionToMessage(SUCCESS_REACTION_EMOTE, commandContext.getGuild().getIdLong(), commandContext.getMessage());
}
}

View File

@@ -0,0 +1 @@
abstracto.emoteNames.postReaction=warnReaction,successReaction