[AB-150] creating repost detection feature including configuration and documentation

adding http and hash service
adding ability to add default emotes to a message to message service
adding message embedded listener to wrap the embedded event
adding custom channel groups which can be defined by modules, in case a change on a channel group (only created and updated) happens a listener is available in order to sync the state in dependant areas
changing command receiver re-throwing abstracto runtime exceptions in order to display them better
changing channel group parameter handler to throw an exception in case the channel group was not found
adding User in a server parameter handler
split channel not found exception to be able to differentiate between not found in database and not found in guild
changing exception handling in command received handler to handle the case for only one parameter handler future which failed (the whole single future failed, which was not reported)
changing parameter type of `removeFromChannelGroup` to AChannel in order to be able to delete channels in the database via ID
moving method to mock utils for mocking consumer
removing parameter validation from commands, as it should be done in the command received handler and parameter handlers anyway
This commit is contained in:
Sheldan
2020-12-04 00:38:18 +01:00
parent e966c710ce
commit 325264a325
249 changed files with 5310 additions and 686 deletions

View File

@@ -34,7 +34,6 @@ public class Ban extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
String defaultReason = templateService.renderSimpleTemplate(BAN_DEFAULT_REASON_TEMPLATE);

View File

@@ -29,7 +29,6 @@ public class BanId extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Long userId = (Long) parameters.get(0);
String defaultReason = templateService.renderSimpleTemplate(Ban.BAN_DEFAULT_REASON_TEMPLATE);

View File

@@ -25,7 +25,6 @@ public class DecayAllWarnings extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
return warnService.decayAllWarningsForServer(commandContext.getUserInitiatedContext().getServer())
.thenApply(aVoid -> CommandResult.fromSuccess());
}

View File

@@ -34,7 +34,6 @@ public class DeleteNote extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Long id = (Long) commandContext.getParameters().getParameters().get(0);
if(userNoteManagementService.noteExists(id, commandContext.getUserInitiatedContext().getServer())) {
userNoteManagementService.deleteNote(id, commandContext.getUserInitiatedContext().getServer());

View File

@@ -29,7 +29,6 @@ public class DeleteWarning extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Long warnId = (Long) commandContext.getParameters().getParameters().get(0);
Optional<Warning> optional = warnManagementService.findByIdOptional(warnId, commandContext.getGuild().getIdLong());
optional.ifPresent(warning -> warnManagementService.deleteWarning(warning));

View File

@@ -32,7 +32,6 @@ public class Kick extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
String defaultReason = templateService.renderSimpleTemplate(KICK_DEFAULT_REASON_TEMPLATE);

View File

@@ -37,7 +37,6 @@ public class Purge extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
Integer amountOfMessages = (Integer) commandContext.getParameters().getParameters().get(0);
Member memberToPurgeMessagesOf = null;
if(commandContext.getParameters().getParameters().size() == 2) {

View File

@@ -28,7 +28,6 @@ public class SlowMode extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
TextChannel channel;
String durationString = (String) commandContext.getParameters().getParameters().get(0);
Duration duration;

View File

@@ -30,7 +30,6 @@ public class UserNoteCommand extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
String text = (String) parameters.get(1);

View File

@@ -49,7 +49,6 @@ public class UserNotes extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
List<UserNote> userNotes;

View File

@@ -34,7 +34,6 @@ public class Warn extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
String defaultReason = templateService.renderSimpleTemplate(WARN_DEFAULT_REASON_TEMPLATE);

View File

@@ -52,7 +52,6 @@ public class Warnings extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Warning> warnsToDisplay;
if(!commandContext.getParameters().getParameters().isEmpty()) {
Member member = (Member) commandContext.getParameters().getParameters().get(0);

View File

@@ -31,7 +31,6 @@ public class Mute extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
Duration duration = (Duration) parameters.get(1);

View File

@@ -30,7 +30,6 @@ public class SetMuteRole extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
checkParameters(commandContext);
Role jdaRole = (Role) commandContext.getParameters().getParameters().get(0);
ARole role = roleManagementService.findRole(jdaRole.getIdLong());
muteRoleManagementService.setMuteRoleForServer(commandContext.getUserInitiatedContext().getServer(), role);

View File

@@ -39,7 +39,6 @@ public class UnMute extends AbstractConditionableCommand {
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
checkParameters(commandContext);
List<Object> parameters = commandContext.getParameters().getParameters();
Member member = (Member) parameters.get(0);
AUserInAServer userToUnMute = userInServerManagementService.loadUser(member);

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.moderation.service;
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
import dev.sheldan.abstracto.core.exception.ChannelNotInGuildException;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.service.BotService;
import lombok.extern.slf4j.Slf4j;
@@ -41,7 +41,7 @@ public class SlowModeServiceBean implements SlowModeService {
TextChannel textChannel = textChannelOptional.get();
return this.setSlowMode(textChannel, duration);
} else {
throw new ChannelNotFoundException(channel.getId());
throw new ChannelNotInGuildException(channel.getId());
}
}
}

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.models.template.commands.BanIdLog;
@@ -69,18 +67,6 @@ public class BanIdTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.models.template.commands.BanLog;
@@ -68,16 +66,6 @@ public class BanTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.command.execution.ResultState;
@@ -53,16 +51,6 @@ public class DeleteNoteTest {
Assert.assertNotNull(result.getMessage());
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AServer;
@@ -52,17 +50,6 @@ public class DeleteWarningTest {
CommandTestUtilities.checkSuccessfulCompletion(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.models.template.commands.KickLogModel;
@@ -70,17 +68,6 @@ public class KickTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.command.execution.ResultState;
@@ -54,16 +52,6 @@ public class PurgeTest {
Assert.assertEquals(ResultState.SELF_DESTRUCT, result.join().getResult());
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.service.SlowModeService;
@@ -68,16 +66,6 @@ public class SlowModeTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,6 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AServer;
@@ -47,11 +46,6 @@ public class UserNoteCommandTest {
CommandTestUtilities.checkSuccessfulCompletion(result);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,6 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
@@ -106,11 +105,6 @@ public class UserNotesTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.models.template.commands.WarnContext;
@@ -66,16 +64,6 @@ public class WarnTest {
CommandTestUtilities.checkSuccessfulCompletionAsync(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.moderation.commands;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import com.jagrosh.jdautilities.menu.Paginator;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
@@ -108,11 +107,6 @@ public class WarningsTest {
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands.mute;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.moderation.models.template.commands.MuteContext;
@@ -47,16 +45,6 @@ public class MuteTest {
Assert.assertEquals(parameters.getAuthor(), muteLog.getMutingUser());
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands.mute;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.ARole;
@@ -46,16 +44,6 @@ public class SetMuteRoleTest {
CommandTestUtilities.checkSuccessfulCompletion(result);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTest(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTest(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -1,7 +1,5 @@
package dev.sheldan.abstracto.moderation.commands.mute;
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterTypeException;
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
@@ -65,16 +63,6 @@ public class UnMuteTest {
testUnit.executeAsync(parameters);
}
@Test(expected = InsufficientParametersException.class)
public void testTooLittleParameters() {
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
}
@Test(expected = IncorrectParameterTypeException.class)
public void testIncorrectParameterType() {
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
}
@Test
public void validateCommand() {
CommandConfigValidator.validateCommandConfiguration(testUnit.getConfiguration());

View File

@@ -22,8 +22,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import static dev.sheldan.abstracto.core.test.MockUtils.mockQueueDoubleVoidConsumer;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
@@ -114,7 +114,7 @@ public class PurgeServiceBeanTest {
setupFirstMessageHistoryMocks();
setupStatusMessageMocks();
mockConsumer(deleteMessagesAction);
mockQueueDoubleVoidConsumer(deleteMessagesAction);
CompletableFuture<Void> futures = testUnit.purgeMessagesInChannel(amountToDelete, textChannel, START_MESSAGE_ID, null);
futures.whenComplete((aVoid, throwable) -> Assert.assertNull(throwable));
verify(deleteStatusAction, times(1)).queueAfter(5, TimeUnit.SECONDS);
@@ -136,7 +136,7 @@ public class PurgeServiceBeanTest {
setupStatusMessageMocks();
AuditableRestAction auditableRestAction = Mockito.mock(AuditableRestAction.class);
when(firstMessage.delete()).thenReturn(auditableRestAction);
mockConsumer(auditableRestAction);
mockQueueDoubleVoidConsumer(auditableRestAction);
CompletableFuture<Void> futures = testUnit.purgeMessagesInChannel(amountToDelete, textChannel, START_MESSAGE_ID, purgedMember);
futures.whenComplete((aVoid, throwable) -> Assert.assertNull(throwable));
verify(deleteStatusAction, times(1)).queueAfter(5, TimeUnit.SECONDS);
@@ -194,7 +194,7 @@ public class PurgeServiceBeanTest {
when(textChannel.deleteMessages(secondMessagesToDelete)).thenReturn(secondDeleteMessagesAction);
mockConsumer(secondDeleteMessagesAction);
mockQueueDoubleVoidConsumer(secondDeleteMessagesAction);
CompletableFuture<Void> futures = testUnit.purgeMessagesInChannel(amountToDelete, textChannel, START_MESSAGE_ID, purgedMember);
futures.whenComplete((aVoid, throwable) -> Assert.assertNull(throwable));
verify(deleteStatusAction, times(1)).queueAfter(5, TimeUnit.SECONDS);
@@ -233,7 +233,7 @@ public class PurgeServiceBeanTest {
setupFirstMessages(firstMessage, deletableMessageId, secondMessage, deletableMessageId2, messageAuthor);
setupMembersWithAuthorId();
setupFirstMessageHistoryMocks();
mockConsumer(deleteMessagesAction);
mockQueueDoubleVoidConsumer(deleteMessagesAction);
setupStatusMessageMocks();
}
@@ -261,16 +261,7 @@ public class PurgeServiceBeanTest {
when(secondMessageToMock.getAuthor()).thenReturn(author);
}
private void mockConsumer(RestAction secondDeleteMessagesAction) {
doAnswer(invocationOnMock -> {
Object consumerObj = invocationOnMock.getArguments()[0];
if(consumerObj instanceof Consumer) {
Consumer<Void> consumer = (Consumer) consumerObj;
consumer.accept(null);
}
return null;
}).when(secondDeleteMessagesAction).queue(any(Consumer.class), any(Consumer.class));
}
private Long getDeletableMessageId() {
return TimeUtil.getDiscordTimestamp((System.currentTimeMillis() - (7 * 24 * 60 * 60 * 1000)));

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.moderation.service;
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
import dev.sheldan.abstracto.core.exception.ChannelNotInGuildException;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.BotService;
@@ -79,7 +79,7 @@ public class SlowModeServiceBeanTest {
testUnit.setSlowMode(channel, duration);
}
@Test(expected = ChannelNotFoundException.class)
@Test(expected = ChannelNotInGuildException.class)
public void testSlowModeInAChannelNotFound() {
AServer server = MockUtils.getServer();
AChannel aChannel = MockUtils.getTextChannel(server, 5L);