fixing command alternatives being required

fixing filename for export emote stats
fixing reaction report message update
This commit is contained in:
Sheldan
2022-08-01 22:59:48 +02:00
parent 0a4238c9f5
commit b747516881
5 changed files with 18 additions and 13 deletions

View File

@@ -7,10 +7,9 @@ import org.springframework.stereotype.Repository;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
@Repository
public interface ReactionReportRepository extends JpaRepository<ReactionReport, Long> {
List<ReactionReport> findByReportedUserAndCreatedLessThan(AUserInAServer aUserInAServer, Instant maxCreated);
List<ReactionReport> findByReportedUserAndCreatedGreaterThan(AUserInAServer aUserInAServer, Instant maxCreated);
}

View File

@@ -31,7 +31,7 @@ public class ReactionReportManagementServiceBean implements ReactionReportManage
@Override
public Optional<ReactionReport> findRecentReactionReportAboutUser(AUserInAServer aUserInAServer, Duration maxAge) {
Instant maxCreation = Instant.now().minus(maxAge);
List<ReactionReport> foundReports = repository.findByReportedUserAndCreatedLessThan(aUserInAServer, maxCreation);
List<ReactionReport> foundReports = repository.findByReportedUserAndCreatedGreaterThan(aUserInAServer, maxCreation);
return foundReports.isEmpty() ? Optional.empty() : Optional.of(foundReports.get(0));
}

View File

@@ -89,6 +89,7 @@ public class ExportEmoteStats extends AbstractConditionableCommand {
.emotes(usedEmotes)
.guild(commandContext.getGuild())
.downloadDate(Instant.now())
.serverId(commandContext.getGuild().getIdLong())
.requester(commandContext.getAuthor())
.statsSince(toUseForModel)
.build();

View File

@@ -33,6 +33,7 @@ public class DownloadEmoteStatsModel {
* The {@link Member} who requested the export
*/
private Member requester;
private Long serverId;
/**
* A list of {@link UsedEmote} which are part of the export
*/

View File

@@ -75,7 +75,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
@Autowired
private List<CommandParameterHandler> parameterHandlers;
@Autowired
@Autowired(required = false)
private List<CommandAlternative> commandAlternatives;
@Autowired
@@ -149,6 +149,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
return null;
});
} else {
if(commandAlternatives != null) {
Optional<CommandAlternative> foundAlternativeOptional = commandAlternatives
.stream()
.filter(commandAlternative -> commandAlternative.matches(result.getParameter()))
@@ -159,6 +160,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
foundAlternative.execute(result.getParameter(), message);
}
}
}
} catch (Exception e) {
reportException(event, null, e, String.format("Exception when executing command from message %d in message %d in guild %d."
, message.getIdLong(), event.getChannel().getIdLong(), event.getGuild().getIdLong()));
@@ -553,8 +555,10 @@ public class CommandReceivedHandler extends ListenerAdapter {
metricService.registerCounter(COMMANDS_PROCESSED_COUNTER, "Commands processed");
metricService.registerCounter(COMMANDS_WRONG_PARAMETER_COUNTER, "Commands with incorrect parameter");
this.parameterHandlers = parameterHandlers.stream().sorted(comparing(CommandParameterHandler::getPriority)).collect(Collectors.toList());
if(commandAlternatives != null) {
this.commandAlternatives = commandAlternatives.stream().sorted(comparing(Prioritized::getPriority)).collect(Collectors.toList());
}
}
@Getter
@Builder