[AB-247/AB-252] fixing issue with set experience role failing to consider the correct experience roles

adding levelRoles command
ignoring bots from experience gain
adding a bit more logging to user experience handling
This commit is contained in:
Sheldan
2021-05-26 01:22:37 +02:00
parent c4fe73b3f8
commit 184271ff7c
27 changed files with 353 additions and 126 deletions

View File

@@ -9,6 +9,7 @@ import dev.sheldan.abstracto.core.command.handler.provided.RoleParameterHandler;
import dev.sheldan.abstracto.core.command.service.CommandService;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +24,9 @@ public class ARoleParameterHandlerImpl implements ARoleParameterHandler {
@Autowired
private RoleService roleService;
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private CommandService commandService;
@@ -36,7 +40,12 @@ public class ARoleParameterHandlerImpl implements ARoleParameterHandler {
Parameter cloned = commandService.cloneParameter(param);
cloned.setType(Role.class);
Role role = (Role) roleParameterHandler.handle(input, iterators, cloned, context, command);
return roleService.getFakeRoleFromRole(role);
if(role != null) {
return roleService.getFakeRoleFromRole(role);
}
Long roleId = Long.parseLong(((String) input.getValue()).trim());
roleManagementService.findRole(roleId);
return roleService.getFakeRoleFromId(roleId);
}
@Override

View File

@@ -269,6 +269,11 @@ public class RoleServiceBean implements RoleService {
.build();
}
@Override
public ARole getFakeRoleFromId(Long roleId) {
return ARole.builder().id(roleId).fake(true).build();
}
@PostConstruct
public void postConstruct() {
metricService.registerCounter(ROLE_ASSIGNED_METRIC, "Amount of roles assigned");