mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 19:56:29 +00:00
added utility module
added ability to create/accept/reject suggestions them made commands async, because a lot of operations behave like that in case the database is needed in an async operation, this needs to be in a separate transactional service fixed ordering of Long parameters (server > channel > message) added initial emote handling (no adding of emotes yet) fixed creation of AUserInAServer, in case the user did not exist yet, when loading changed PostTargetService to return Futures instead of being a void, in order to be able to act on the message posted set logging level to debug fixed help for different commands (templates had wrong naming)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>utility-int</artifactId>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.abstracto.utility;
|
||||
|
||||
import dev.sheldan.abstracto.command.Module;
|
||||
import dev.sheldan.abstracto.command.module.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Utility implements Module {
|
||||
|
||||
public static final String UTILITY = "utility";
|
||||
|
||||
@Override
|
||||
public ModuleInfo getInfo() {
|
||||
return ModuleInfo.builder().name(UTILITY).description("General utilities").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentModule() {
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package dev.sheldan.abstracto.utility.models;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.AChannelType;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Table(name="suggestion")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter @Setter
|
||||
public class Suggestion {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
private Long id;
|
||||
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "suggesterId")
|
||||
private AUserInAServer suggester;
|
||||
|
||||
@Getter
|
||||
private Long messageId;
|
||||
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "channelId")
|
||||
private AChannel channel;
|
||||
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "serverId")
|
||||
private AServer server;
|
||||
|
||||
@Getter
|
||||
private Instant suggestionDate;
|
||||
|
||||
@Getter
|
||||
@Enumerated(EnumType.STRING)
|
||||
private SuggestionState state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.sheldan.abstracto.utility.models;
|
||||
|
||||
public enum SuggestionState {
|
||||
NEW, ACCEPTED, REJECTED
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.sheldan.abstracto.utility.models.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.UserInitiatedServerContext;
|
||||
import dev.sheldan.abstracto.utility.models.Suggestion;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
@Getter @Setter @SuperBuilder
|
||||
public class SuggestionLog extends UserInitiatedServerContext {
|
||||
private Suggestion suggestion;
|
||||
private Member suggester;
|
||||
private String text;
|
||||
private String reason;
|
||||
private Long originalMessageId;
|
||||
private Long originalChannelId;
|
||||
private String originalMessageUrl;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.abstracto.utility.service;
|
||||
|
||||
import dev.sheldan.abstracto.utility.models.template.SuggestionLog;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.utility.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.utility.models.Suggestion;
|
||||
import dev.sheldan.abstracto.utility.models.SuggestionState;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
public interface SuggestionManagementService {
|
||||
Suggestion createSuggestion(Member suggester, String text);
|
||||
Suggestion createSuggestion(AUserInAServer suggester, String text);
|
||||
Suggestion getSuggestion(Long suggestionId);
|
||||
void setPostedMessage(Suggestion suggestion, Message message);
|
||||
void setSuggestionState(Suggestion suggestion, SuggestionState newState);
|
||||
}
|
||||
Reference in New Issue
Block a user