mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 03:45:57 +00:00
[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:
@@ -31,7 +31,6 @@ public class DisableExpForRole extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
ARole role = (ARole) parameters.get(0);
|
||||
ARole actualRole = roleManagementService.findRole(role.getId());
|
||||
|
||||
@@ -32,7 +32,6 @@ public class DisableExpGain extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Member para = (Member) commandContext.getParameters().getParameters().get(0);
|
||||
AUserInAServer userInAServer = userInServerManagementService.loadUser(para);
|
||||
aUserExperienceService.disableExperienceForUser(userInAServer);
|
||||
|
||||
@@ -31,7 +31,6 @@ public class EnableExpForRole extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
ARole role = (ARole) commandContext.getParameters().getParameters().get(0);
|
||||
ARole actualRole = roleManagementService.findRole(role.getId());
|
||||
if(disabledExpRoleManagementService.isExperienceDisabledForRole(actualRole)) {
|
||||
|
||||
@@ -32,7 +32,6 @@ public class EnableExpGain extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Member para = (Member) commandContext.getParameters().getParameters().get(0);
|
||||
AUserInAServer userInAServer = userInServerManagementService.loadUser(para);
|
||||
aUserExperienceService.enableExperienceForUser(userInAServer);
|
||||
|
||||
@@ -30,7 +30,6 @@ public class ExpScale extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Double scale = (Double) commandContext.getParameters().getParameters().get(0);
|
||||
Long guildId = commandContext.getGuild().getIdLong();
|
||||
configService.setDoubleValue(EXP_MULTIPLIER_KEY, guildId, scale);
|
||||
|
||||
@@ -54,7 +54,6 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
// parameter is optional, in case its not present, we default to the 0th page
|
||||
Integer page = !parameters.isEmpty() ? (Integer) parameters.get(0) : 1;
|
||||
|
||||
@@ -42,7 +42,6 @@ public class ListDisabledExperienceRoles extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<ADisabledExpRole> disabledRolesForServer = disabledExpRoleManagementService.getDisabledRolesForServer(commandContext.getUserInitiatedContext().getServer());
|
||||
DisabledExperienceRolesModel disabledExperienceRolesModel = (DisabledExperienceRolesModel) ContextConverter.fromCommandContext(commandContext, DisabledExperienceRolesModel.class);
|
||||
disabledRolesForServer.forEach(aDisabledExpRole -> {
|
||||
|
||||
@@ -66,7 +66,6 @@ public class Rank extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
RankModel rankModel = (RankModel) ContextConverter.slimFromCommandContext(commandContext, RankModel.class);
|
||||
LeaderBoardEntry userRank = userExperienceService.getRankOfUserInServer(commandContext.getUserInitiatedContext().getAUserInAServer());
|
||||
CompletableFuture<LeaderBoardEntryModel> future = converter.fromLeaderBoardEntry(userRank);
|
||||
|
||||
@@ -41,7 +41,6 @@ public class SetExpRole extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Integer level = (Integer) commandContext.getParameters().getParameters().get(0);
|
||||
Role role = (Role) commandContext.getParameters().getParameters().get(1);
|
||||
log.info("Setting role {} to be used for level {} on server {}", role.getId(), level, role.getGuild().getId());
|
||||
|
||||
@@ -33,7 +33,6 @@ public class UnSetExpRole extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
ARole role = (ARole) commandContext.getParameters().getParameters().get(0);
|
||||
ARole actualRole = roleManagementService.findRole(role.getId());
|
||||
// do not check for the existence of the role, because if the role was deleted, users should be able
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.ARole;
|
||||
@@ -34,16 +32,6 @@ public class DisableExpForRoleTest {
|
||||
@Mock
|
||||
private DisabledExpRoleManagementService disabledExpRoleManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteCommandForNotDisabledRole() {
|
||||
executeDisableExpForRoleTest(false, 1);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.AUserInAServer;
|
||||
@@ -34,16 +32,6 @@ public class DisableExpGainTest {
|
||||
@Mock
|
||||
private UserInServerManagementService userInServerManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisableExpForMember() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.ARole;
|
||||
@@ -32,16 +30,6 @@ public class EnableExpForRoleTest {
|
||||
@Mock
|
||||
private RoleManagementService roleManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteCommandForNotDisabledRole() {
|
||||
executeEnableExpForRoleTest(false, 0);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.AUserInAServer;
|
||||
@@ -34,16 +32,6 @@ public class EnableExpGainTest {
|
||||
@Mock
|
||||
private UserInServerManagementService userInServerManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnableExpForMember() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.service.ConfigService;
|
||||
@@ -26,16 +24,6 @@ public class ExpScaleTest {
|
||||
@Mock
|
||||
private ConfigService configService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTest(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetExpScaleForGuild() {
|
||||
double newScale = 4.5;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.service.ChannelService;
|
||||
@@ -44,11 +43,6 @@ public class LeaderBoardCommandTest {
|
||||
@Mock
|
||||
private LeaderBoardModelConverter converter;
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeaderBoardWithNoParameter() {
|
||||
testLeaderBoardCommand(CommandTestUtilities.getNoParameters(), 1);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.service.RoleService;
|
||||
@@ -37,28 +35,6 @@ public class SetExpRoleTest {
|
||||
@Mock
|
||||
private RoleManagementService roleManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testRoleMissing() {
|
||||
CommandContext context = CommandTestUtilities.getWithParameters(Arrays.asList(4));
|
||||
testUnit.executeAsync(context);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testLevelProvidedButNotRole() {
|
||||
CommandContext context = CommandTestUtilities.getWithParameters(Arrays.asList(4, ""));
|
||||
testUnit.executeAsync(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setExpRole() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.sheldan.abstracto.experience.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.ARole;
|
||||
@@ -34,16 +32,6 @@ public class UnSetExpRoleTest {
|
||||
@Mock
|
||||
private RoleManagementService roleManagementService;
|
||||
|
||||
@Test(expected = InsufficientParametersException.class)
|
||||
public void testTooLittleParameters() {
|
||||
CommandTestUtilities.executeNoParametersTestAsync(testUnit);
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectParameterTypeException.class)
|
||||
public void testIncorrectParameterType() {
|
||||
CommandTestUtilities.executeWrongParametersTestAsync(testUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setUnSetExpRole() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
|
||||
Reference in New Issue
Block a user