mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-09 10:12:19 +00:00
[AB-99/AB-66] changed commands to use embeds for exceptions instead of direct messages
added models instead of using HashMaps for exceptions added a lot of exceptions for different cases refactored a few commands to be fully async instead of fire and forget
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.command.condition;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.exception.IncorrectParameter;
|
||||
import dev.sheldan.abstracto.core.command.exception.InsufficientParameters;
|
||||
import dev.sheldan.abstracto.core.command.exception.IncorrectParameterException;
|
||||
import dev.sheldan.abstracto.core.command.exception.InsufficientParametersException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -52,17 +52,17 @@ public abstract class AbstractConditionableCommand implements ConditionalCommand
|
||||
if(context.getParameters() != null && context.getParameters().getParameters() != null && context.getParameters().getParameters().size() >= i) {
|
||||
boolean parameterIsPresent = i < context.getParameters().getParameters().size();
|
||||
if(parameterIsPresent && !desiredType.isInstance(context.getParameters().getParameters().get(i))) {
|
||||
throw new IncorrectParameter(this, desiredType, parameter.getName());
|
||||
throw new IncorrectParameterException(this, desiredType, parameter.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMandatoryExp(CommandContext context, int i, Parameter parameter, Class desiredType) {
|
||||
if(context.getParameters() == null || context.getParameters().getParameters() == null || context.getParameters().getParameters().isEmpty() || i >= context.getParameters().getParameters().size()) {
|
||||
throw new InsufficientParameters(this, parameter.getName());
|
||||
throw new InsufficientParametersException(this, parameter.getName());
|
||||
}
|
||||
if(!desiredType.isInstance(context.getParameters().getParameters().get(i))) {
|
||||
throw new IncorrectParameter(this, desiredType, parameter.getName());
|
||||
throw new IncorrectParameterException(this, desiredType, parameter.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.command.condition;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.exception.CommandDisabledException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.service.ChannelGroupCommandService;
|
||||
@@ -21,6 +22,9 @@ public class CommandDisabledCondition implements CommandCondition {
|
||||
public ConditionResult shouldExecute(CommandContext context, Command command) {
|
||||
ACommand acommand = commandManagementService.findCommandByName(command.getConfiguration().getName());
|
||||
Boolean booleanResult = channelGroupCommandService.isCommandEnabled(acommand, context.getUserInitiatedContext().getChannel());
|
||||
if(!booleanResult) {
|
||||
throw new CommandDisabledException();
|
||||
}
|
||||
return ConditionResult.builder().result(booleanResult).reason("Command is disabled.").build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.command.condition;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.exception.InsufficientPermissionException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.models.exception.InsufficientPermissionMessage;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommandInAServer;
|
||||
import dev.sheldan.abstracto.core.command.service.management.CommandInServerManagementService;
|
||||
@@ -10,9 +10,12 @@ import dev.sheldan.abstracto.core.command.service.management.CommandManagementSe
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import dev.sheldan.abstracto.core.service.RoleService;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CommandDisallowedCondition implements CommandCondition {
|
||||
|
||||
@@ -41,11 +44,7 @@ public class CommandDisallowedCondition implements CommandCondition {
|
||||
return ConditionResult.builder().result(true).build();
|
||||
}
|
||||
}
|
||||
InsufficientPermissionMessage insufficientPermissionMessage = InsufficientPermissionMessage
|
||||
.builder()
|
||||
.allowedRoles(roleService.getRolesFromGuild(commandForServer.getAllowedRoles()))
|
||||
.build();
|
||||
String message = templateService.renderTemplate("insufficient_role", insufficientPermissionMessage);
|
||||
return ConditionResult.builder().result(false).reason(message).build();
|
||||
List<Role> allowedRoles = roleService.getRolesFromGuild(commandForServer.getAllowedRoles());
|
||||
throw new InsufficientPermissionException(allowedRoles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.command.condition;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.exception.FeatureDisabledException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.models.exception.FeatureDisabledMessage;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
@@ -30,11 +30,7 @@ public class FeatureEnabledCondition implements CommandCondition {
|
||||
if(feature != null) {
|
||||
featureFlagValue = featureFlagService.getFeatureFlagValue(feature, context.getGuild().getIdLong());
|
||||
if(!featureFlagValue) {
|
||||
FeatureDisabledMessage featureDisabledMessage = FeatureDisabledMessage
|
||||
.builder()
|
||||
.featureConfig(featureConfigService.getFeatureDisplayForFeature(feature))
|
||||
.build();
|
||||
reason = templateService.renderTemplate("feature_disabled_message", featureDisabledMessage);
|
||||
throw new FeatureDisabledException(featureConfigService.getFeatureDisplayForFeature(feature));
|
||||
}
|
||||
}
|
||||
return ConditionResult.builder().reason(reason).result(featureFlagValue).build();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.command.condition;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.exception.ImmuneUserException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.models.exception.UserImmuneMessage;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommandInAServer;
|
||||
import dev.sheldan.abstracto.core.command.service.management.CommandInServerManagementService;
|
||||
@@ -41,17 +41,11 @@ public class ImmuneUserCondition implements CommandCondition {
|
||||
Member member = any.get();
|
||||
for (ARole role : commandForServer.getImmuneRoles()) {
|
||||
if (roleService.memberHasRole(member, role)) {
|
||||
UserImmuneMessage userImmuneMessage = UserImmuneMessage
|
||||
.builder()
|
||||
.role(roleService.getRoleFromGuild(role))
|
||||
.build();
|
||||
String message = templateService.renderTemplate("immune_role", userImmuneMessage);
|
||||
return ConditionResult.builder().result(false).reason(message).build();
|
||||
throw new ImmuneUserException(roleService.getRoleFromGuild(role));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConditionResult.builder().result(true).build();
|
||||
|
||||
}
|
||||
|
||||
private Member toMember(Object o) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class CommandConfiguration {
|
||||
private boolean async = false;
|
||||
|
||||
@Builder.Default
|
||||
private boolean reportsException = false;
|
||||
private boolean supportsEmbedException = false;
|
||||
|
||||
@Builder.Default
|
||||
private List<Parameter> parameters = new ArrayList<>();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
|
||||
public class AbstractoTemplatedException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String templateKey;
|
||||
|
||||
public AbstractoTemplatedException(String message, String templateKey) {
|
||||
super(message);
|
||||
this.templateKey = templateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return templateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ChannelAlreadyInChannelGroupExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class ChannelAlreadyInChannelGroupException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final ChannelAlreadyInChannelGroupExceptionModel model;
|
||||
|
||||
public ChannelAlreadyInChannelGroupException(AChannel channel, AChannelGroup group) {
|
||||
super("Channel is already part of channel group");
|
||||
this.model = ChannelAlreadyInChannelGroupExceptionModel.builder().channel(channel).channelGroup(group).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "channel_already_in_channel_group_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ChannelGroupExistsExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ChannelGroupExistsException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private String name;
|
||||
private final ChannelGroupExistsExceptionModel model;
|
||||
|
||||
public ChannelGroupExistsException(String name) {
|
||||
super("");
|
||||
this.name = name;
|
||||
super("Channel group already exists");
|
||||
this.model = ChannelGroupExistsExceptionModel.builder().name(name).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,8 +20,6 @@ public class ChannelGroupExistsException extends AbstractoRunTimeException imple
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("name", this.name);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ChannelGroupNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ChannelGroupNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private String name;
|
||||
private List<String> available;
|
||||
private final ChannelGroupNotFoundExceptionModel model;
|
||||
|
||||
public ChannelGroupNotFoundException(String key, List<String> available) {
|
||||
super("");
|
||||
this.name = key;
|
||||
this.available = available;
|
||||
super("Channel group not found");
|
||||
this.model = ChannelGroupNotFoundExceptionModel.builder().name(key).available(available).build();
|
||||
}
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
@@ -23,9 +21,6 @@ public class ChannelGroupNotFoundException extends AbstractoRunTimeException imp
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("name", this.name);
|
||||
param.put("available", String.join(", ", this.available));
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ChannelNotInChannelGroupExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class ChannelNotInChannelGroupException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final ChannelNotInChannelGroupExceptionModel model;
|
||||
|
||||
public ChannelNotInChannelGroupException(AChannel channel, AChannelGroup group) {
|
||||
super("Channel is already part of channel group");
|
||||
this.model = ChannelNotInChannelGroupExceptionModel.builder().channel(channel).channelGroup(group).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "channel_not_in_channel_group_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,15 @@ package dev.sheldan.abstracto.core.command.exception;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class CommandNotFound extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
public CommandNotFound(String s) {
|
||||
super(s);
|
||||
}
|
||||
public class CommandDisabledException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "command_not_found";
|
||||
return "command_disabled_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return null;
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,12 @@ import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class CommandNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
public CommandNotFoundException() {
|
||||
super("");
|
||||
}
|
||||
public CommandNotFoundException(String text) {
|
||||
super(text);
|
||||
super("Command not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "command_not_found_exception_text";
|
||||
return "command_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.CommandParameterKeyValueWrongTypeModel;
|
||||
import dev.sheldan.abstracto.core.command.models.exception.CommandParameterKeyValueWrongTypeExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
@@ -8,11 +8,11 @@ import java.util.List;
|
||||
|
||||
public class CommandParameterKeyValueWrongTypeException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private CommandParameterKeyValueWrongTypeModel model;
|
||||
private CommandParameterKeyValueWrongTypeExceptionModel model;
|
||||
|
||||
public CommandParameterKeyValueWrongTypeException(List<String> expectedValues) {
|
||||
super("Command parameter value did not have expected values present");
|
||||
this.model = CommandParameterKeyValueWrongTypeModel.builder().expectedValues(expectedValues).build();
|
||||
this.model = CommandParameterKeyValueWrongTypeExceptionModel.builder().expectedValues(expectedValues).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.FeatureDisabledExceptionModel;
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class FeatureDisabledException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final FeatureDisabledExceptionModel model;
|
||||
|
||||
public FeatureDisabledException(FeatureConfig featureConfig) {
|
||||
super("Feature has been disabled");
|
||||
this.model = FeatureDisabledExceptionModel.builder().featureConfig(featureConfig).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "feature_disabled_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ImmuneUserExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
public class ImmuneUserException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final transient ImmuneUserExceptionModel model;
|
||||
|
||||
public ImmuneUserException(Role role) {
|
||||
super("User is immune against the command");
|
||||
this.model = ImmuneUserExceptionModel.builder().role(role).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "immune_role_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class IncorrectParameter extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
private final Class clazz;
|
||||
|
||||
public IncorrectParameter(Command command, Class expected, String parameterName) {
|
||||
super("");
|
||||
this.command = command;
|
||||
this.parameterName = parameterName;
|
||||
this.clazz = expected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "incorrect_parameters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> model = new HashMap<>();
|
||||
model.put("parameterName", parameterName);
|
||||
model.put("class", this.clazz);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.IncorrectParameterExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class IncorrectParameterException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final IncorrectParameterExceptionModel model;
|
||||
|
||||
public IncorrectParameterException(Command command, Class expected, String parameterName) {
|
||||
super("Incorrect parameter given for parameter");
|
||||
this.model = IncorrectParameterExceptionModel.builder().clazz(expected).parameterName(parameterName).command(command).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "incorrect_parameters_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Getter
|
||||
public class InsufficientParameters extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
|
||||
public InsufficientParameters(Command command, String parameterName) {
|
||||
super("");
|
||||
this.command = command;
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "insufficient_parameters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> model = new HashMap<>();
|
||||
model.put("parameterName", parameterName);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.InsufficientParametersExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
|
||||
public class InsufficientParametersException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final InsufficientParametersExceptionModel model;
|
||||
|
||||
public InsufficientParametersException(Command command, String parameterName) {
|
||||
super("Insufficient parameters given for command");
|
||||
this.model = InsufficientParametersExceptionModel.builder().command(command).parameterName(parameterName).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "insufficient_parameters_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.InsufficientPermissionExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InsufficientPermissionException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final InsufficientPermissionExceptionModel model;
|
||||
|
||||
public InsufficientPermissionException(List<Role> allowedRoles) {
|
||||
super("Insufficient permissions, required role not given.");
|
||||
this.model = InsufficientPermissionExceptionModel.builder().allowedRoles(allowedRoles).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "insufficient_role_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ParameterTooLong extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
private final Integer actualLength;
|
||||
private final Integer maximumLength;
|
||||
|
||||
public ParameterTooLong(String s, Command command, String parameterName, Integer actualLength, Integer maximumLength) {
|
||||
super(s);
|
||||
this.command = command;
|
||||
this.parameterName = parameterName;
|
||||
this.actualLength = actualLength;
|
||||
this.maximumLength = maximumLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "parameter_too_long";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> model = new HashMap<>();
|
||||
model.put("parameterName", parameterName);
|
||||
model.put("actualLength", actualLength);
|
||||
model.put("maximumLength", maximumLength);
|
||||
model.put("command", command);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ParameterTooLongExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class ParameterTooLongException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final ParameterTooLongExceptionModel model;
|
||||
|
||||
public ParameterTooLongException(Command command, String parameterName, Integer actualLength, Integer maximumLength) {
|
||||
super("Parameter was too long for command");
|
||||
this.model = ParameterTooLongExceptionModel
|
||||
.builder()
|
||||
.actualLength(actualLength)
|
||||
.maximumLength(maximumLength)
|
||||
.parameterName(parameterName)
|
||||
.command(command)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "parameter_too_long_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ChannelAlreadyInChannelGroupExceptionModel implements Serializable {
|
||||
private AChannel channel;
|
||||
private AChannelGroup channelGroup;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ChannelGroupExistsExceptionModel implements Serializable {
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ChannelGroupNotFoundExceptionModel implements Serializable {
|
||||
private String name;
|
||||
private List<String> available;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ChannelNotInChannelGroupExceptionModel implements Serializable {
|
||||
private AChannel channel;
|
||||
private AChannelGroup channelGroup;
|
||||
}
|
||||
@@ -9,6 +9,6 @@ import java.util.List;
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class CommandParameterKeyValueWrongTypeModel {
|
||||
public class CommandParameterKeyValueWrongTypeExceptionModel {
|
||||
private List<String> expectedValues;
|
||||
}
|
||||
@@ -5,9 +5,11 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
public class FeatureDisabledMessage {
|
||||
public class FeatureDisabledExceptionModel implements Serializable {
|
||||
private FeatureConfig featureConfig;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.FullUser;
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -10,7 +11,8 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Builder
|
||||
public class GenericExceptionModel {
|
||||
private FullUser user;
|
||||
private FullUserInServer user;
|
||||
private FullUser fullUser;
|
||||
private Throwable throwable;
|
||||
|
||||
public Templatable getTemplate() {
|
||||
|
||||
@@ -8,6 +8,6 @@ import net.dv8tion.jda.api.entities.Role;
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class UserImmuneMessage {
|
||||
public class ImmuneUserExceptionModel {
|
||||
private Role role;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class IncorrectParameterExceptionModel implements Serializable {
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
private final Class clazz;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class InsufficientParametersExceptionModel implements Serializable {
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class InsufficientPermissionExceptionModel implements Serializable {
|
||||
private transient List<Role> allowedRoles;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ParameterTooLongExceptionModel implements Serializable {
|
||||
private final transient Command command;
|
||||
private final String parameterName;
|
||||
private final Integer actualLength;
|
||||
private final Integer maximumLength;
|
||||
}
|
||||
@@ -3,7 +3,14 @@ package dev.sheldan.abstracto.core.command.service;
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||
|
||||
public interface ExceptionService {
|
||||
CommandResult reportExceptionToContext(Throwable exception, CommandContext context, Command command);
|
||||
void reportExceptionToGuildMessageReceivedContext(Throwable exception, GuildMessageReceivedEvent event);
|
||||
void reportExceptionToPrivateMessageReceivedContext(Throwable exception, PrivateMessageReceivedEvent event);
|
||||
void reportExceptionToChannel(Throwable exception, MessageChannel channel, Member member);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package dev.sheldan.abstracto.core.config;
|
||||
import dev.sheldan.abstracto.core.interactive.SetupStep;
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public interface FeatureConfig {
|
||||
public interface FeatureConfig extends Serializable {
|
||||
FeatureEnum getFeature();
|
||||
default List<FeatureConfig> getRequiredFeatures() {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.CategoryNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CategoryNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Long categoryId;
|
||||
private final Long guildId;
|
||||
private final CategoryNotFoundExceptionModel model;
|
||||
|
||||
public CategoryNotFoundException(Long categoryId, Long guildId) {
|
||||
super("");
|
||||
this.categoryId = categoryId;
|
||||
this.guildId = guildId;
|
||||
super("Category not found");
|
||||
this.model = CategoryNotFoundExceptionModel.builder().categoryId(categoryId).guildId(guildId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,9 +19,6 @@ public class CategoryNotFoundException extends AbstractoRunTimeException impleme
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("categoryId", this.categoryId);
|
||||
param.put("guildId", this.guildId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.ChannelNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ChannelNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Long channelId;
|
||||
private final ChannelNotFoundExceptionModel model;
|
||||
|
||||
public ChannelNotFoundException(Long channelId) {
|
||||
super("Channel not found in database");
|
||||
this.channelId = channelId;
|
||||
this.model = ChannelNotFoundExceptionModel.builder().channelId(channelId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,8 +19,6 @@ public class ChannelNotFoundException extends AbstractoRunTimeException implemen
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("channelId", this.channelId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.ConfigurationKeyNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ConfigurationKeyNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String key;
|
||||
private final ConfigurationKeyNotFoundExceptionModel model;
|
||||
|
||||
public ConfigurationKeyNotFoundException(String key) {
|
||||
super("");
|
||||
this.key = key;
|
||||
super("Configuration key not found");
|
||||
this.model = ConfigurationKeyNotFoundExceptionModel.builder().key(key).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,8 +19,6 @@ public class ConfigurationKeyNotFoundException extends AbstractoRunTimeException
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("key", this.key);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteConfiguredButNotUsableExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class ConfiguredEmoteNotUsableException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final EmoteConfiguredButNotUsableExceptionModel model;
|
||||
|
||||
public ConfiguredEmoteNotUsableException(AEmote emote) {
|
||||
super("Emote was configured in database, but is not usable by the bot anymore.");
|
||||
this.model = EmoteConfiguredButNotUsableExceptionModel.builder().emote(emote).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "emote_defined_but_not_usable_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.DurationFormatExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DurationFormatException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String invalidFormat;
|
||||
private final List<String> validFormats;
|
||||
private final DurationFormatExceptionModel model;
|
||||
|
||||
|
||||
public DurationFormatException(String wrongFormat, List<String> validFormats) {
|
||||
super("");
|
||||
this.invalidFormat = wrongFormat;
|
||||
this.validFormats = validFormats;
|
||||
super("Duration format exception ");
|
||||
this.model = DurationFormatExceptionModel.builder().invalidFormat(wrongFormat).validFormats(validFormats).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,9 +22,6 @@ public class DurationFormatException extends AbstractoRunTimeException implement
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("format", this.invalidFormat);
|
||||
param.put("valid", String.join(", ", this.validFormats));
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotDefinedExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class EmoteNotDefinedException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String emoteKey;
|
||||
private final EmoteNotDefinedExceptionModel model;
|
||||
|
||||
public EmoteNotDefinedException(String key) {
|
||||
super("");
|
||||
this.emoteKey = key;
|
||||
super(String.format("Emote %s not defined", key));
|
||||
this.model = EmoteNotDefinedExceptionModel.builder().emoteKey(key).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,8 +19,6 @@ public class EmoteNotDefinedException extends AbstractoRunTimeException implemen
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("emoteKey", this.emoteKey);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class EmoteNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String emoteKey;
|
||||
private final List<String> available;
|
||||
private final EmoteNotFoundExceptionModel model;
|
||||
|
||||
public EmoteNotFoundException(String key, List<String> availableEmotes) {
|
||||
super("");
|
||||
this.emoteKey = key;
|
||||
this.available = availableEmotes;
|
||||
super("Emote not found");
|
||||
this.model = EmoteNotFoundExceptionModel.builder().emoteKey(key).available(availableEmotes).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,9 +21,6 @@ public class EmoteNotFoundException extends AbstractoRunTimeException implements
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("emoteKey", this.emoteKey);
|
||||
param.put("available", String.join(",", this.available));
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotFoundInDbExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class EmoteNotFoundInDbException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Integer emoteId;
|
||||
private final EmoteNotFoundInDbExceptionModel model;
|
||||
|
||||
public EmoteNotFoundInDbException(Integer emoteId) {
|
||||
super("");
|
||||
this.emoteId = emoteId;
|
||||
super("Emote not found in database");
|
||||
this.model = EmoteNotFoundInDbExceptionModel.builder().emoteId(emoteId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,8 +19,6 @@ public class EmoteNotFoundInDbException extends AbstractoRunTimeException implem
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put("emoteId", this.emoteId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotInServerModel;
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotInServerExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class ExceptionNotInServerException extends AbstractoRunTimeException implements Templatable {
|
||||
public class EmoteNotInServerException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private EmoteNotInServerModel model;
|
||||
private final EmoteNotInServerExceptionModel model;
|
||||
|
||||
public ExceptionNotInServerException(Long emoteId) {
|
||||
public EmoteNotInServerException(Long emoteId) {
|
||||
super("Emote not available in server");
|
||||
this.model = EmoteNotInServerModel.builder().emoteId(emoteId).build();
|
||||
this.model = EmoteNotInServerExceptionModel.builder().emoteId(emoteId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,21 +1,21 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotUsable;
|
||||
import dev.sheldan.abstracto.core.models.exception.EmoteNotUsableExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
|
||||
public class EmoteNotUsableException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private EmoteNotUsable model;
|
||||
private final EmoteNotUsableExceptionModel model;
|
||||
|
||||
public EmoteNotUsableException(Emote emote) {
|
||||
super("");
|
||||
this.model = EmoteNotUsable.builder().emote(emote).build();
|
||||
super(String.format("Emote %s not usable by bot.", emote.getId()));
|
||||
this.model = EmoteNotUsableExceptionModel.builder().emote(emote).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "emote_not_usable";
|
||||
return "emote_not_usable_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,31 +1,26 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.FeatureModeNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FeatureModeNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String featureMode;
|
||||
private final List<String> availableModes;
|
||||
private final FeatureModeNotFoundExceptionModel model;
|
||||
|
||||
public FeatureModeNotFoundException(String message, String featureMode, List<String> availableModes) {
|
||||
super(message);
|
||||
this.featureMode = featureMode;
|
||||
this.availableModes = availableModes;
|
||||
public FeatureModeNotFoundException(String featureMode, List<String> availableModes) {
|
||||
super("Feature mode not found.");
|
||||
this.model = FeatureModeNotFoundExceptionModel.builder().availableModes(availableModes).featureMode(featureMode).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "feature_mode_not_found";
|
||||
return "feature_mode_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("featureMode", this.featureMode);
|
||||
parameters.put("availableModes", this.availableModes);
|
||||
return parameters;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.FeatureNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FeatureNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String feature;
|
||||
private final List<String> availableFeatures;
|
||||
private final FeatureNotFoundExceptionModel model;
|
||||
|
||||
public FeatureNotFoundException(String feature, List<String> availableFeatures) {
|
||||
super("Feature not found.");
|
||||
this.model = FeatureNotFoundExceptionModel.builder().featureName(feature).availableFeatures(availableFeatures).build();
|
||||
|
||||
public FeatureNotFoundException(String message, String feature, List<String> availableFeatures) {
|
||||
super(message);
|
||||
this.feature = feature;
|
||||
this.availableFeatures = availableFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "feature_not_found";
|
||||
return "feature_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("featureName", this.feature);
|
||||
parameters.put("availableFeatures", this.availableFeatures);
|
||||
return parameters;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.GuildNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GuildNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
private final Long guildId;
|
||||
|
||||
public GuildNotFoundException(String message, Long guildId) {
|
||||
super(message);
|
||||
this.guildId = guildId;
|
||||
}
|
||||
private final GuildNotFoundExceptionModel model;
|
||||
|
||||
public GuildNotFoundException(Long guildId) {
|
||||
super("");
|
||||
this.guildId = guildId;
|
||||
super("Guild not found");
|
||||
this.model = GuildNotFoundExceptionModel.builder().guildId(guildId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,8 +18,6 @@ public class GuildNotFoundException extends AbstractoRunTimeException implements
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("guildId", this.guildId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.sheldan.abstracto.templating.Templatable;
|
||||
public class MemberNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
public MemberNotFoundException() {
|
||||
super("");
|
||||
super("Member was not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.PostTargetNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PostTargetNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String postTargetKey;
|
||||
private final PostTargetNotFoundExceptionModel model;
|
||||
|
||||
public PostTargetNotFoundException(String key) {
|
||||
super("");
|
||||
this.postTargetKey = key;
|
||||
super("Post target not found");
|
||||
this.model = PostTargetNotFoundExceptionModel.builder().postTargetKey(key).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "post_target_not_found";
|
||||
return "post_target_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("key", this.postTargetKey);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,26 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.PostTargetNotValidExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class PostTargetNotValidException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final String postTargetKey;
|
||||
private final List<String> availableTargets;
|
||||
private final PostTargetNotValidExceptionModel model;
|
||||
|
||||
public PostTargetNotValidException(String key, List<String> available) {
|
||||
super("");
|
||||
this.postTargetKey = key;
|
||||
this.availableTargets = available;
|
||||
super("Given post target was not in the list of valid post targets");
|
||||
this.model = PostTargetNotValidExceptionModel.builder().availableTargets(available).postTargetKey(key).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "post_target_not_valid";
|
||||
return "post_target_not_valid_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, String> param = new HashMap<>();
|
||||
param.put("key", this.postTargetKey);
|
||||
param.put("available", String.join(",", this.availableTargets));
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import dev.sheldan.abstracto.core.models.exception.RoleDeletedModel;
|
||||
import dev.sheldan.abstracto.core.models.exception.RoleDeletedExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
public class RoleDeletedException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private RoleDeletedModel model;
|
||||
private final RoleDeletedExceptionModel model;
|
||||
|
||||
public RoleDeletedException(ARole role) {
|
||||
super("Role has been marked as deleted and cannot be used.");
|
||||
this.model = RoleDeletedModel.builder().role(role).build();
|
||||
this.model = RoleDeletedExceptionModel.builder().role(role).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "";
|
||||
return "role_disabled_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.RoleNotFoundInDBExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RoleNotFoundInDBException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Long roleId;
|
||||
private final RoleNotFoundInDBExceptionModel model;
|
||||
|
||||
public RoleNotFoundInDBException(Long roleId) {
|
||||
super("");
|
||||
this.roleId = roleId;
|
||||
super("Role not found in database");
|
||||
this.model = RoleNotFoundInDBExceptionModel.builder().roleId(roleId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,8 +19,6 @@ public class RoleNotFoundInDBException extends AbstractoRunTimeException impleme
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("roleId", this.roleId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.RoleNotFoundInGuildExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RoleNotFoundInGuildException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Long roleId;
|
||||
private final Long serverId;
|
||||
private final RoleNotFoundInGuildExceptionModel model;
|
||||
|
||||
public RoleNotFoundInGuildException(Long roleId, Long serverId) {
|
||||
super("");
|
||||
this.roleId = roleId;
|
||||
this.serverId = serverId;
|
||||
super("Role not found in guild");
|
||||
this.model = RoleNotFoundInGuildExceptionModel.builder().roleId(roleId).serverId(serverId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,9 +19,6 @@ public class RoleNotFoundInGuildException extends AbstractoRunTimeException impl
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("roleId", this.roleId);
|
||||
param.put("serverId", this.serverId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.exception.UserInServerNotFoundExceptionModel;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class UserInServerNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final Long userInServerId;
|
||||
private final UserInServerNotFoundExceptionModel model;
|
||||
|
||||
public UserInServerNotFoundException(Long userInServerId) {
|
||||
super("");
|
||||
this.userInServerId = userInServerId;
|
||||
super("User in server not found");
|
||||
this.model = UserInServerNotFoundExceptionModel.builder().userInServerId(userInServerId).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "core_user_in_server_not_found_exception";
|
||||
return "user_in_server_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Long> param = new HashMap<>();
|
||||
param.put("userInServerId", this.userInServerId);
|
||||
return param;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,20 @@ package dev.sheldan.abstracto.core.interactive;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SetupStepException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final SetupStepExceptionModel model;
|
||||
|
||||
public SetupStepException(Throwable throwable) {
|
||||
super("", throwable);
|
||||
super("Failed to execute setup step", throwable);
|
||||
SetupStepExceptionModel.SetupStepExceptionModelBuilder builder = SetupStepExceptionModel.builder();
|
||||
if(getCause() instanceof Templatable) {
|
||||
Templatable templatable = (Templatable) getCause();
|
||||
builder.templateKey(templatable.getTemplateName());
|
||||
builder.templateModel(templatable.getTemplateModel());
|
||||
}
|
||||
builder.message(getCause().getMessage());
|
||||
this.model = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -17,14 +26,6 @@ public class SetupStepException extends AbstractoRunTimeException implements Tem
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> stringStringHashMap = new HashMap<>();
|
||||
if(getCause() instanceof Templatable) {
|
||||
Templatable templatable = (Templatable) getCause();
|
||||
stringStringHashMap.put("templateKey", templatable.getTemplateName());
|
||||
stringStringHashMap.put("templateModel", templatable.getTemplateModel());
|
||||
}
|
||||
stringStringHashMap.put("message", getCause().getMessage());
|
||||
|
||||
return stringStringHashMap;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.interactive;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class SetupStepExceptionModel implements Serializable {
|
||||
private String templateKey;
|
||||
private transient Object templateModel;
|
||||
private String message;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.io.Serializable;
|
||||
@Builder
|
||||
public class FullEmote implements Serializable {
|
||||
private AEmote fakeEmote;
|
||||
private Emote emote;
|
||||
private transient Emote emote;
|
||||
|
||||
public String getEmoteRepr() {
|
||||
if(!fakeEmote.getCustom()) {
|
||||
|
||||
@@ -6,12 +6,14 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FullRole {
|
||||
public class FullRole implements Serializable {
|
||||
private ARole role;
|
||||
private Role serverRole;
|
||||
private transient Role serverRole;
|
||||
|
||||
public String getRoleRepr() {
|
||||
if(serverRole != null) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
public class FullUser {
|
||||
private AUserInAServer aUserInAServer;
|
||||
private Member member;
|
||||
private AUser auser;
|
||||
private User user;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.sheldan.abstracto.core.models;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
public class FullUserInServer implements Serializable {
|
||||
private AUserInAServer aUserInAServer;
|
||||
private transient Member member;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class CategoryNotFoundExceptionModel implements Serializable {
|
||||
private final Long categoryId;
|
||||
private final Long guildId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ChannelNotFoundExceptionModel implements Serializable {
|
||||
private final Long channelId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ConfigurationKeyNotFoundExceptionModel implements Serializable {
|
||||
private final String key;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Builder
|
||||
public class DurationFormatExceptionModel implements Serializable {
|
||||
private final String invalidFormat;
|
||||
private final List<String> validFormats;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class EmoteConfiguredButNotUsableExceptionModel implements Serializable {
|
||||
private final AEmote emote;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class EmoteNotDefinedExceptionModel implements Serializable {
|
||||
private final String emoteKey;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class EmoteNotFoundExceptionModel implements Serializable {
|
||||
private final String emoteKey;
|
||||
private final List<String> available;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class EmoteNotFoundInDbExceptionModel implements Serializable {
|
||||
private final Integer emoteId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class EmoteNotInServerExceptionModel implements Serializable {
|
||||
private final Long emoteId;
|
||||
}
|
||||
@@ -5,9 +5,10 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class EmoteNotUsable {
|
||||
private Emote emote;
|
||||
public class EmoteNotUsableExceptionModel implements Serializable {
|
||||
private transient Emote emote;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class FeatureModeNotFoundExceptionModel implements Serializable {
|
||||
private final String featureMode;
|
||||
private final List<String> availableModes;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class FeatureNotFoundExceptionModel implements Serializable {
|
||||
private final String featureName;
|
||||
private final List<String> availableFeatures;
|
||||
}
|
||||
@@ -4,9 +4,10 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class EmoteNotInServerModel {
|
||||
private Long emoteId;
|
||||
public class GuildNotFoundExceptionModel implements Serializable {
|
||||
private final Long guildId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class PostTargetNotFoundExceptionModel implements Serializable {
|
||||
private final String postTargetKey;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class PostTargetNotValidExceptionModel implements Serializable {
|
||||
private final String postTargetKey;
|
||||
private final List<String> availableTargets;
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class RoleDeletedModel {
|
||||
private ARole role;
|
||||
public class RoleDeletedExceptionModel {
|
||||
private final ARole role;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class RoleNotFoundInDBExceptionModel implements Serializable {
|
||||
private final Long roleId;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class RoleNotFoundInGuildExceptionModel implements Serializable {
|
||||
private final Long roleId;
|
||||
private final Long serverId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.core.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class UserInServerNotFoundExceptionModel implements Serializable {
|
||||
private final Long userInServerId;
|
||||
}
|
||||
@@ -6,8 +6,9 @@ import dev.sheldan.abstracto.core.interactive.SetupExecution;
|
||||
import dev.sheldan.abstracto.core.models.AServerChannelUserId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface SetupService {
|
||||
void performSetup(FeatureConfig featureConfig, AServerChannelUserId user, Long initialMessageId);
|
||||
void executeSetup(FeatureConfig featureConfig, List<SetupExecution> steps, AServerChannelUserId user, List<DelayedActionConfig> delayedActionConfigs);
|
||||
CompletableFuture<Void> performSetup(FeatureConfig featureConfig, AServerChannelUserId user, Long initialMessageId);
|
||||
CompletableFuture<Void> executeSetup(FeatureConfig featureConfig, List<SetupExecution> steps, AServerChannelUserId user, List<DelayedActionConfig> delayedActionConfigs);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.sheldan.abstracto.core.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.FullUser;
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
|
||||
public interface UserInServerService {
|
||||
FullUser getFullUser(AUserInAServer aUserInAServer);
|
||||
FullUserInServer getFullUser(AUserInAServer aUserInAServer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user