mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-22 14:00:10 +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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user