[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:
Sheldan
2020-08-29 01:24:06 +02:00
parent fbb36ae9d5
commit 552ecc26b8
285 changed files with 1607 additions and 847 deletions

View File

@@ -2,15 +2,14 @@ package dev.sheldan.abstracto.utility.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.templating.Templatable;
import java.util.HashMap;
import dev.sheldan.abstracto.utility.models.exception.ReminderNotFoundExceptionModel;
public class ReminderNotFoundException extends AbstractoRunTimeException implements Templatable {
private Long reminderId;
private final ReminderNotFoundExceptionModel model;
public ReminderNotFoundException(Long reminderId) {
super("");
this.reminderId = reminderId;
super("Reminder does not exist");
this.model = ReminderNotFoundExceptionModel.builder().reminderId(reminderId).build();
}
@Override
@@ -20,8 +19,6 @@ public class ReminderNotFoundException extends AbstractoRunTimeException impleme
@Override
public Object getTemplateModel() {
HashMap<String, Long> params = new HashMap<>();
params.put("id", this.reminderId);
return params;
return model;
}
}

View File

@@ -2,15 +2,15 @@ package dev.sheldan.abstracto.utility.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.templating.Templatable;
import java.util.HashMap;
import dev.sheldan.abstracto.utility.models.exception.SuggestionNotFoundExceptionModel;
public class SuggestionNotFoundException extends AbstractoRunTimeException implements Templatable {
private Long suggestionId;
private final SuggestionNotFoundExceptionModel model;
public SuggestionNotFoundException(Long suggestionId) {
super("");
this.suggestionId = suggestionId;
super("Suggestion not found");
this.model = SuggestionNotFoundExceptionModel.builder().suggestionId(suggestionId).build();
}
@Override
@@ -20,8 +20,6 @@ public class SuggestionNotFoundException extends AbstractoRunTimeException imple
@Override
public Object getTemplateModel() {
HashMap<String, Long> params = new HashMap<>();
params.put("id", this.suggestionId);
return params;
return model;
}
}

View File

@@ -1,9 +1,20 @@
package dev.sheldan.abstracto.utility.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.templating.Templatable;
public class SuggestionUpdateException extends AbstractoRunTimeException {
public SuggestionUpdateException(String message) {
super(message);
public class SuggestionUpdateException extends AbstractoRunTimeException implements Templatable {
public SuggestionUpdateException() {
super("Not possible to update suggestion.");
}
@Override
public String getTemplateName() {
return "suggestion_update_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,13 @@
package dev.sheldan.abstracto.utility.models.exception;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Builder
public class ReminderNotFoundExceptionModel implements Serializable {
private final Long reminderId;
}

View File

@@ -0,0 +1,13 @@
package dev.sheldan.abstracto.utility.models.exception;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Builder
public class SuggestionNotFoundExceptionModel implements Serializable {
private final Long suggestionId;
}

View File

@@ -3,8 +3,10 @@ package dev.sheldan.abstracto.utility.service;
import dev.sheldan.abstracto.utility.models.template.commands.SuggestionLog;
import net.dv8tion.jda.api.entities.Member;
import java.util.concurrent.CompletableFuture;
public interface SuggestionService {
void createSuggestion(Member member, String text, SuggestionLog log);
void acceptSuggestion(Long suggestionId, String text, SuggestionLog log);
void rejectSuggestion(Long suggestionId, String text, SuggestionLog log);
CompletableFuture<Void> createSuggestion(Member member, String text, SuggestionLog log);
CompletableFuture<Void> acceptSuggestion(Long suggestionId, String text, SuggestionLog log);
CompletableFuture<Void> rejectSuggestion(Long suggestionId, String text, SuggestionLog log);
}